extractedLnx/linux-2.5.9/drivers/net/sk98lin/skge.c_GetConfiguration.c
static void GetConfiguration(
SK_AC *pAC) /* pointer to the adapter context structure */
{
SK_I32 Port; /* preferred port */
int AutoNeg; /* auto negotiation off (0) or on (1) */
int DuplexCap; /* duplex capabilities (0=both, 1=full, 2=half */
int MSMode; /* master / slave mode selection */
SK_BOOL AutoSet;
SK_BOOL DupSet;
/*
* The two parameters AutoNeg. and DuplexCap. map to one configuration
* parameter. The mapping is described by this table:
* DuplexCap -> | both | full | half |
* AutoNeg | | | |
* -----------------------------------------------------------------
* Off | illegal | Full | Half |
* -----------------------------------------------------------------
* On | AutoBoth | AutoFull | AutoHalf |
* -----------------------------------------------------------------
* Sense | AutoSense | AutoSense | AutoSense |
*/
int Capabilities[3][3] =
{ { -1, SK_LMODE_FULL, SK_LMODE_HALF},
{SK_LMODE_AUTOBOTH, SK_LMODE_AUTOFULL, SK_LMODE_AUTOHALF},
{SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE} };
#define DC_BOTH 0
#define DC_FULL 1
#define DC_HALF 2
#define AN_OFF 0
#define AN_ON 1
#define AN_SENS 2
/* settings for port A */
AutoNeg = AN_SENS; /* default: do auto Sense */
AutoSet = SK_FALSE;
if (AutoNeg_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
AutoNeg_A[pAC->Index] != NULL) {
AutoSet = SK_TRUE;
if (strcmp(AutoNeg_A[pAC->Index],"")==0) {
AutoSet = SK_FALSE;
}
else if (strcmp(AutoNeg_A[pAC->Index],"On")==0) {
AutoNeg = AN_ON;
}
else if (strcmp(AutoNeg_A[pAC->Index],"Off")==0) {
AutoNeg = AN_OFF;
}
else if (strcmp(AutoNeg_A[pAC->Index],"Sense")==0) {
AutoNeg = AN_SENS;
}
else printk("%s: Illegal value for AutoNeg_A\n",
pAC->dev[0]->name);
}
DuplexCap = DC_BOTH;
DupSet = SK_FALSE;
if (DupCap_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
DupCap_A[pAC->Index] != NULL) {
DupSet = SK_TRUE;
if (strcmp(DupCap_A[pAC->Index],"")==0) {
DupSet = SK_FALSE;
}
else if (strcmp(DupCap_A[pAC->Index],"Both")==0) {
DuplexCap = DC_BOTH;
}
else if (strcmp(DupCap_A[pAC->Index],"Full")==0) {
DuplexCap = DC_FULL;
}
else if (strcmp(DupCap_A[pAC->Index],"Half")==0) {
DuplexCap = DC_HALF;
}
else printk("%s: Illegal value for DupCap_A\n",
pAC->dev[0]->name);
}
/* check for illegal combinations */
if (AutoSet && AutoNeg==AN_SENS && DupSet) {
printk("%s, Port A: DuplexCapabilities"
" ignored using Sense mode\n", pAC->dev[0]->name);
}
if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
printk("%s, Port A: Illegal combination"
" of values AutoNeg. and DuplexCap.\n Using "
"Full Duplex\n", pAC->dev[0]->name);
DuplexCap = DC_FULL;
}
if (AutoSet && AutoNeg==AN_OFF && !DupSet) {
DuplexCap = DC_FULL;
}
if (!AutoSet && DupSet) {
printk("%s, Port A: Duplex setting not"
" possible in\n default AutoNegotiation mode"
" (Sense).\n Using AutoNegotiation On\n",
pAC->dev[0]->name);
AutoNeg = AN_ON;
}
/* set the desired mode */
pAC->GIni.GP[0].PLinkModeConf =
Capabilities[AutoNeg][DuplexCap];
pAC->GIni.GP[0].PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;
if (FlowCtrl_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
FlowCtrl_A[pAC->Index] != NULL) {
if (strcmp(FlowCtrl_A[pAC->Index],"") == 0) {
}
else if (strcmp(FlowCtrl_A[pAC->Index],"SymOrRem") == 0) {
pAC->GIni.GP[0].PFlowCtrlMode =
SK_FLOW_MODE_SYM_OR_REM;
}
else if (strcmp(FlowCtrl_A[pAC->Index],"Sym")==0) {
pAC->GIni.GP[0].PFlowCtrlMode =
SK_FLOW_MODE_SYMMETRIC;
}
else if (strcmp(FlowCtrl_A[pAC->Index],"LocSend")==0) {
pAC->GIni.GP[0].PFlowCtrlMode =
SK_FLOW_MODE_LOC_SEND;
}
else if (strcmp(FlowCtrl_A[pAC->Index],"None")==0) {
pAC->GIni.GP[0].PFlowCtrlMode =
SK_FLOW_MODE_NONE;
}
else printk("Illegal value for FlowCtrl_A\n");
}
if (AutoNeg==AN_OFF && pAC->GIni.GP[0].PFlowCtrlMode!=
SK_FLOW_MODE_NONE) {
printk("%s, Port A: FlowControl"
" impossible without AutoNegotiation,"
" disabled\n", pAC->dev[0]->name);
pAC->GIni.GP[0].PFlowCtrlMode = SK_FLOW_MODE_NONE;
}
MSMode = SK_MS_MODE_AUTO; /* default: do auto select */
if (Role_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
Role_A[pAC->Index] != NULL) {
if (strcmp(Role_A[pAC->Index],"")==0) {
}
else if (strcmp(Role_A[pAC->Index],"Auto")==0) {
MSMode = SK_MS_MODE_AUTO;
}
else if (strcmp(Role_A[pAC->Index],"Master")==0) {
MSMode = SK_MS_MODE_MASTER;
}
else if (strcmp(Role_A[pAC->Index],"Slave")==0) {
MSMode = SK_MS_MODE_SLAVE;
}
else printk("%s: Illegal value for Role_A\n",
pAC->dev[0]->name);
}
pAC->GIni.GP[0].PMSMode = MSMode;
/* settings for port B */
AutoNeg = AN_SENS; /* default: do auto Sense */
AutoSet = SK_FALSE;
if (AutoNeg_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
AutoNeg_B[pAC->Index] != NULL) {
AutoSet = SK_TRUE;
if (strcmp(AutoNeg_B[pAC->Index],"")==0) {
AutoSet = SK_FALSE;
}
else if (strcmp(AutoNeg_B[pAC->Index],"On")==0) {
AutoNeg = AN_ON;
}
else if (strcmp(AutoNeg_B[pAC->Index],"Off")==0) {
AutoNeg = AN_OFF;
}
else if (strcmp(AutoNeg_B[pAC->Index],"Sense")==0) {
AutoNeg = AN_SENS;
}
else printk("Illegal value for AutoNeg_B\n");
}
DuplexCap = DC_BOTH;
DupSet = SK_FALSE;
if (DupCap_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
DupCap_B[pAC->Index] != NULL) {
DupSet = SK_TRUE;
if (strcmp(DupCap_B[pAC->Index],"")==0) {
DupSet = SK_FALSE;
}
else if (strcmp(DupCap_B[pAC->Index],"Both")==0) {
DuplexCap = DC_BOTH;
}
else if (strcmp(DupCap_B[pAC->Index],"Full")==0) {
DuplexCap = DC_FULL;
}
else if (strcmp(DupCap_B[pAC->Index],"Half")==0) {
DuplexCap = DC_HALF;
}
else printk("Illegal value for DupCap_B\n");
}
/* check for illegal combinations */
if (AutoSet && AutoNeg==AN_SENS && DupSet) {
printk("%s, Port B: DuplexCapabilities"
" ignored using Sense mode\n", pAC->dev[1]->name);
}
if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
printk("%s, Port B: Illegal combination"
" of values AutoNeg. and DuplexCap.\n Using "
"Full Duplex\n", pAC->dev[1]->name);
DuplexCap = DC_FULL;
}
if (AutoSet && AutoNeg==AN_OFF && !DupSet) {
DuplexCap = DC_FULL;
}
if (!AutoSet && DupSet) {
printk("%s, Port B: Duplex setting not"
" possible in\n default AutoNegotiation mode"
" (Sense).\n Using AutoNegotiation On\n",
pAC->dev[1]->name);
AutoNeg = AN_ON;
}
/* set the desired mode */
pAC->GIni.GP[1].PLinkModeConf =
Capabilities[AutoNeg][DuplexCap];
pAC->GIni.GP[1].PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;
if (FlowCtrl_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
FlowCtrl_B[pAC->Index] != NULL) {
if (strcmp(FlowCtrl_B[pAC->Index],"") == 0) {
}
else if (strcmp(FlowCtrl_B[pAC->Index],"SymOrRem") == 0) {
pAC->GIni.GP[1].PFlowCtrlMode =
SK_FLOW_MODE_SYM_OR_REM;
}
else if (strcmp(FlowCtrl_B[pAC->Index],"Sym")==0) {
pAC->GIni.GP[1].PFlowCtrlMode =
SK_FLOW_MODE_SYMMETRIC;
}
else if (strcmp(FlowCtrl_B[pAC->Index],"LocSend")==0) {
pAC->GIni.GP[1].PFlowCtrlMode =
SK_FLOW_MODE_LOC_SEND;
}
else if (strcmp(FlowCtrl_B[pAC->Index],"None")==0) {
pAC->GIni.GP[1].PFlowCtrlMode =
SK_FLOW_MODE_NONE;
}
else printk("Illegal value for FlowCtrl_B\n");
}
if (AutoNeg==AN_OFF && pAC->GIni.GP[1].PFlowCtrlMode!=
SK_FLOW_MODE_NONE) {
printk("%s, Port B: FlowControl"
" impossible without AutoNegotiation,"
" disabled\n", pAC->dev[1]->name);
pAC->GIni.GP[1].PFlowCtrlMode = SK_FLOW_MODE_NONE;
}
MSMode = SK_MS_MODE_AUTO; /* default: do auto select */
if (Role_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
Role_B[pAC->Index] != NULL) {
if (strcmp(Role_B[pAC->Index],"")==0) {
}
else if (strcmp(Role_B[pAC->Index],"Auto")==0) {
MSMode = SK_MS_MODE_AUTO;
}
else if (strcmp(Role_B[pAC->Index],"Master")==0) {
MSMode = SK_MS_MODE_MASTER;
}
else if (strcmp(Role_B[pAC->Index],"Slave")==0) {
MSMode = SK_MS_MODE_SLAVE;
}
else printk("%s: Illegal value for Role_B\n",
pAC->dev[1]->name);
}
pAC->GIni.GP[1].PMSMode = MSMode;
/* settings for both ports */
pAC->ActivePort = 0;
if (PrefPort != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
PrefPort[pAC->Index] != NULL) {
if (strcmp(PrefPort[pAC->Index],"") == 0) { /* Auto */
pAC->ActivePort = 0;
pAC->Rlmt.Net[0].Preference = -1; /* auto */
pAC->Rlmt.Net[0].PrefPort = 0;
}
else if (strcmp(PrefPort[pAC->Index],"A") == 0) {
/*
* do not set ActivePort here, thus a port
* switch is issued after net up.
*/
Port = 0;
pAC->Rlmt.Net[0].Preference = Port;
pAC->Rlmt.Net[0].PrefPort = Port;
}
else if (strcmp(PrefPort[pAC->Index],"B") == 0) {
/*
* do not set ActivePort here, thus a port
* switch is issued after net up.
*/
Port = 1;
pAC->Rlmt.Net[0].Preference = Port;
pAC->Rlmt.Net[0].PrefPort = Port;
}
else printk("%s: Illegal value for PrefPort\n",
pAC->dev[0]->name);
}
pAC->RlmtNets = 1;
if (RlmtMode != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
RlmtMode[pAC->Index] != NULL) {
if (strcmp(RlmtMode[pAC->Index], "") == 0) {
pAC->RlmtMode = 0;
}
else if (strcmp(RlmtMode[pAC->Index], "CheckLinkState") == 0) {
pAC->RlmtMode = SK_RLMT_CHECK_LINK;
}
else if (strcmp(RlmtMode[pAC->Index], "CheckLocalPort") == 0) {
pAC->RlmtMode = SK_RLMT_CHECK_LINK |
SK_RLMT_CHECK_LOC_LINK;
}
else if (strcmp(RlmtMode[pAC->Index], "CheckSeg") == 0) {
pAC->RlmtMode = SK_RLMT_CHECK_LINK |
SK_RLMT_CHECK_LOC_LINK |
SK_RLMT_CHECK_SEG;
}
else if ((strcmp(RlmtMode[pAC->Index], "DualNet") == 0) &&
(pAC->GIni.GIMacsFound == 2)) {
pAC->RlmtMode = SK_RLMT_CHECK_LINK;
pAC->RlmtNets = 2;
}
else {
printk("%s: Illegal value for"
" RlmtMode, using default\n", pAC->dev[0]->name);
printk("MacFound = %d\nRlmtMode = %s", pAC->GIni.GIMacsFound, RlmtMode[pAC->Index]);
pAC->RlmtMode = 0;
}
}
else {
pAC->RlmtMode = 0;
}
} /* GetConfiguration */
Generated by GNU enscript 1.6.4.