177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/* 277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Copyright (C) 1999 - 2010 Intel Corporation. 377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD. 477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * This code was derived from the Intel e1000e Linux driver. 677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * This program is free software; you can redistribute it and/or modify 877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * it under the terms of the GNU General Public License as published by 977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * the Free Software Foundation; version 2 of the License. 1077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 1177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * This program is distributed in the hope that it will be useful, 1277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * but WITHOUT ANY WARRANTY; without even the implied warranty of 1377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * GNU General Public License for more details. 1577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 1677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * You should have received a copy of the GNU General Public License 170ab75ae81da249988bf3c7a38e0a48d4b9be1e0cJeff Kirsher * along with this program; if not, see <http://www.gnu.org/licenses/>. 1877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 1977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 2077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#include "pch_gbe.h" 215e773fdc535cf3f4fa8023fe2ce20dcf774dae8aJoe Perches#include <linux/module.h> /* for __MODULE_STRING */ 2277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 2377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define OPTION_UNSET -1 2477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define OPTION_DISABLED 0 2577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define OPTION_ENABLED 1 2677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 2777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 2877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * TxDescriptors - Transmit Descriptor Count 2977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: PCH_GBE_MIN_TXD - PCH_GBE_MAX_TXD 3077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: PCH_GBE_DEFAULT_TXD 3177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 3277555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int TxDescriptors = OPTION_UNSET; 3377555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(TxDescriptors, int, 0); 3477555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(TxDescriptors, "Number of transmit descriptors"); 3577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 3677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 3777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * RxDescriptors -Receive Descriptor Count 3877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: PCH_GBE_MIN_RXD - PCH_GBE_MAX_RXD 3977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: PCH_GBE_DEFAULT_RXD 4077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 4177555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int RxDescriptors = OPTION_UNSET; 4277555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(RxDescriptors, int, 0); 4377555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(RxDescriptors, "Number of receive descriptors"); 4477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 4577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 4677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Speed - User Specified Speed Override 4777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0, 10, 100, 1000 4877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 0: auto-negotiate at all supported speeds 4977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 10: only link at 10 Mbps 5077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 100: only link at 100 Mbps 5177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 1000: only link at 1000 Mbps 5277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: 0 5377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 5477555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int Speed = OPTION_UNSET; 5577555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(Speed, int, 0); 5677555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(Speed, "Speed setting"); 5777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 5877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 5977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Duplex - User Specified Duplex Override 6077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0-2 6177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 0: auto-negotiate for duplex 6277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 1: only link at half duplex 6377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 2: only link at full duplex 6477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: 0 6577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 6677555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int Duplex = OPTION_UNSET; 6777555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(Duplex, int, 0); 6877555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(Duplex, "Duplex setting"); 6977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 7077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define HALF_DUPLEX 1 7177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define FULL_DUPLEX 2 7277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 7377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 7477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * AutoNeg - Auto-negotiation Advertisement Override 7577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0x01-0x0F, 0x20-0x2F 7677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 7777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * The AutoNeg value is a bit mask describing which speed and duplex 7877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * combinations should be advertised during auto-negotiation. 7977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * The supported speed and duplex modes are listed below 8077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 8177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Bit 7 6 5 4 3 2 1 0 8277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Speed (Mbps) N/A N/A 1000 N/A 100 100 10 10 8377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Duplex Full Full Half Full Half 8477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 8577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: 0x2F (copper) 8677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 8777555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int AutoNeg = OPTION_UNSET; 8877555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(AutoNeg, int, 0); 8977555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(AutoNeg, "Advertised auto-negotiation setting"); 9077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 9177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_10_HALF 0x0001 9277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_10_FULL 0x0002 9377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_100_HALF 0x0004 9477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_100_FULL 0x0008 9577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_1000_HALF 0x0010 /* Not used, just FYI */ 9677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PHY_ADVERTISE_1000_FULL 0x0020 9777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PCH_AUTONEG_ADVERTISE_DEFAULT 0x2F 9877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 9977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 10077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * FlowControl - User Specified Flow Control Override 10177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0-3 10277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 0: No Flow Control 10377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 1: Rx only, respond to PAUSE frames but do not generate them 10477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 2: Tx only, generate PAUSE frames but ignore them on receive 10577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 3: Full Flow Control Support 10677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: Read flow control settings from the EEPROM 10777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 10877555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int FlowControl = OPTION_UNSET; 10977555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(FlowControl, int, 0); 11077555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(FlowControl, "Flow Control setting"); 11177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 11277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/* 11377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * XsumRX - Receive Checksum Offload Enable/Disable 11477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0, 1 11577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 0: disables all checksum offload 11677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 1: enables receive IP/TCP/UDP checksum offload 11777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: PCH_GBE_DEFAULT_RX_CSUM 11877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 11977555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int XsumRX = OPTION_UNSET; 12077555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(XsumRX, int, 0); 12177555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(XsumRX, "Disable or enable Receive Checksum offload"); 12277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 12377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PCH_GBE_DEFAULT_RX_CSUM true /* trueorfalse */ 12477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 12577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/* 12677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * XsumTX - Transmit Checksum Offload Enable/Disable 12777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Valid Range: 0, 1 12877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 0: disables all checksum offload 12977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * - 1: enables transmit IP/TCP/UDP checksum offload 13077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @Default Value: PCH_GBE_DEFAULT_TX_CSUM 13177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 13277555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int XsumTX = OPTION_UNSET; 13377555ee7228234257957fd54daa0b69178906320Masayuki Ohtakemodule_param(XsumTX, int, 0); 13477555ee7228234257957fd54daa0b69178906320Masayuki OhtakeMODULE_PARM_DESC(XsumTX, "Disable or enable Transmit Checksum offload"); 13577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 13677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake#define PCH_GBE_DEFAULT_TX_CSUM true /* trueorfalse */ 13777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 13877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 13977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * pch_gbe_option - Force the MAC's flow control settings 14077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @hw: Pointer to the HW structure 14149ce9c2cda18f62b13055dc715e7b514157c2da8Ben Hutchings * Returns: 14277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 0: Successful. 14377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Negative value: Failed. 14477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 14577555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestruct pch_gbe_option { 14677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake enum { enable_option, range_option, list_option } type; 14777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake char *name; 14877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake char *err; 14977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int def; 15077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake union { 15177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct { /* range_option info */ 15277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int min; 15377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int max; 15477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } r; 15577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct { /* list_option info */ 15677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int nr; 15777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake const struct pch_gbe_opt_list { int i; char *str; } *p; 15877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } l; 15977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } arg; 16077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake}; 16177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 16277555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic const struct pch_gbe_opt_list speed_list[] = { 16377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0, "" }, 16477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { SPEED_10, "" }, 16577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { SPEED_100, "" }, 16677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { SPEED_1000, "" } 16777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake}; 16877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 16977555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic const struct pch_gbe_opt_list dplx_list[] = { 17077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0, "" }, 17177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { HALF_DUPLEX, "" }, 17277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { FULL_DUPLEX, "" } 17377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake}; 17477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 17577555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic const struct pch_gbe_opt_list an_list[] = 17677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake #define AA "AutoNeg advertising " 17777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake {{ 0x01, AA "10/HD" }, 17877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x02, AA "10/FD" }, 17977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x03, AA "10/FD, 10/HD" }, 18077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x04, AA "100/HD" }, 18177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x05, AA "100/HD, 10/HD" }, 18277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x06, AA "100/HD, 10/FD" }, 18377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x07, AA "100/HD, 10/FD, 10/HD" }, 18477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x08, AA "100/FD" }, 18577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x09, AA "100/FD, 10/HD" }, 18677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0a, AA "100/FD, 10/FD" }, 18777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0b, AA "100/FD, 10/FD, 10/HD" }, 18877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0c, AA "100/FD, 100/HD" }, 18977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0d, AA "100/FD, 100/HD, 10/HD" }, 19077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0e, AA "100/FD, 100/HD, 10/FD" }, 19177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" }, 19277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x20, AA "1000/FD" }, 19377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x21, AA "1000/FD, 10/HD" }, 19477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x22, AA "1000/FD, 10/FD" }, 19577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x23, AA "1000/FD, 10/FD, 10/HD" }, 19677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x24, AA "1000/FD, 100/HD" }, 19777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x25, AA "1000/FD, 100/HD, 10/HD" }, 19877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x26, AA "1000/FD, 100/HD, 10/FD" }, 19977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" }, 20077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x28, AA "1000/FD, 100/FD" }, 20177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x29, AA "1000/FD, 100/FD, 10/HD" }, 20277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2a, AA "1000/FD, 100/FD, 10/FD" }, 20377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" }, 20477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2c, AA "1000/FD, 100/FD, 100/HD" }, 20577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" }, 20677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" }, 20777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" } 20877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake}; 20977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 21077555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic const struct pch_gbe_opt_list fc_list[] = { 21177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { PCH_GBE_FC_NONE, "Flow Control Disabled" }, 21277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { PCH_GBE_FC_RX_PAUSE, "Flow Control Receive Only" }, 21377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { PCH_GBE_FC_TX_PAUSE, "Flow Control Transmit Only" }, 21477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { PCH_GBE_FC_FULL, "Flow Control Enabled" } 21577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake}; 21677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 21777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 21877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * pch_gbe_validate_option - Validate option 21977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @value: value 22077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @opt: option 22177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @adapter: Board private structure 22249ce9c2cda18f62b13055dc715e7b514157c2da8Ben Hutchings * Returns: 22377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * 0: Successful. 22477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * Negative value: Failed. 22577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 22677555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic int pch_gbe_validate_option(int *value, 22777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake const struct pch_gbe_option *opt, 22877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct pch_gbe_adapter *adapter) 22977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake{ 23077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if (*value == OPTION_UNSET) { 23177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake *value = opt->def; 23277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return 0; 23377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 23477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 23577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake switch (opt->type) { 23677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case enable_option: 23777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake switch (*value) { 23877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case OPTION_ENABLED: 239453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "%s Enabled\n", opt->name); 24077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return 0; 24177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case OPTION_DISABLED: 242453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "%s Disabled\n", opt->name); 24377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return 0; 24477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 24577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 24677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case range_option: 24777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if (*value >= opt->arg.r.min && *value <= opt->arg.r.max) { 248453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "%s set to %i\n", 249453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko opt->name, *value); 25077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return 0; 25177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 25277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 25377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case list_option: { 25477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int i; 25577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake const struct pch_gbe_opt_list *ent; 25677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 25777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake for (i = 0; i < opt->arg.l.nr; i++) { 25877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake ent = &opt->arg.l.p[i]; 25977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if (*value == ent->i) { 26077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if (ent->str[0] != '\0') 261453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "%s\n", 262453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko ent->str); 26377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return 0; 26477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 26577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 26677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 26777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 26877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake default: 26977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake BUG(); 27077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 27177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 272453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "Invalid %s value specified (%i) %s\n", 273453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko opt->name, *value, opt->err); 27477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake *value = opt->def; 27577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake return -1; 27677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake} 27777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 27877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 27977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * pch_gbe_check_copper_options - Range Checking for Link Options, Copper Version 28077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @adapter: Board private structure 28177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 28277555ee7228234257957fd54daa0b69178906320Masayuki Ohtakestatic void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter) 28377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake{ 28477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct pch_gbe_hw *hw = &adapter->hw; 28577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake int speed, dplx; 28677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 28777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Speed */ 28877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 28977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = list_option, 29077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Speed", 29177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "parameter ignored", 29277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = 0, 29377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .arg = { .l = { .nr = (int)ARRAY_SIZE(speed_list), 29477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .p = speed_list } } 29577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 29677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake speed = Speed; 29777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake pch_gbe_validate_option(&speed, &opt, adapter); 29877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 29977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Duplex */ 30077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 30177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = list_option, 30277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Duplex", 30377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "parameter ignored", 30477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = 0, 30577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .arg = { .l = { .nr = (int)ARRAY_SIZE(dplx_list), 30677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .p = dplx_list } } 30777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 30877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake dplx = Duplex; 30977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake pch_gbe_validate_option(&dplx, &opt, adapter); 31077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 31177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 31277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Autoneg */ 31377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 31477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = list_option, 31577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "AutoNeg", 31677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "parameter ignored", 31777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_AUTONEG_ADVERTISE_DEFAULT, 31877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .arg = { .l = { .nr = (int)ARRAY_SIZE(an_list), 31977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .p = an_list} } 32077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 32177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if (speed || dplx) { 322453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 323453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "AutoNeg specified along with Speed or Duplex, AutoNeg parameter ignored\n"); 32477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = opt.def; 32577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } else { 32673f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter int tmp = AutoNeg; 32773f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter 32873f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter pch_gbe_validate_option(&tmp, &opt, adapter); 32973f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter hw->phy.autoneg_advertised = tmp; 33077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 33177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 33277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 33377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake switch (speed + dplx) { 33477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case 0: 33577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 33677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake if ((speed || dplx)) 337453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 338453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Speed and duplex autonegotiation enabled\n"); 33977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 34077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 34177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 34277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case HALF_DUPLEX: 343453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 344453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Half Duplex specified without Speed\n"); 345453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 346453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Using Autonegotiation at Half Duplex only\n"); 34777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 34877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = PHY_ADVERTISE_10_HALF | 34977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PHY_ADVERTISE_100_HALF; 35077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 35177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 35277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 35377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case FULL_DUPLEX: 354453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 355453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Full Duplex specified without Speed\n"); 356453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 357453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Using Autonegotiation at Full Duplex only\n"); 35877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 35977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = PHY_ADVERTISE_10_FULL | 36077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PHY_ADVERTISE_100_FULL | 36177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PHY_ADVERTISE_1000_FULL; 36277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 36377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_FULL; 36477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 36577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_10: 366453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 367453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "10 Mbps Speed specified without Duplex\n"); 368453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 369453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Using Autonegotiation at 10 Mbps only\n"); 37077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 37177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = PHY_ADVERTISE_10_HALF | 37277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PHY_ADVERTISE_10_FULL; 37377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 37477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 37577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 37677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_10 + HALF_DUPLEX: 377453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "Forcing to 10 Mbps Half Duplex\n"); 37877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 0; 37977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = 0; 38077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 38177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 38277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 38377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_10 + FULL_DUPLEX: 384453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, "Forcing to 10 Mbps Full Duplex\n"); 38577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 0; 38677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = 0; 38777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_10; 38877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_FULL; 38977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 39077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_100: 391453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 392453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "100 Mbps Speed specified without Duplex\n"); 393453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 394453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Using Autonegotiation at 100 Mbps only\n"); 39577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 39677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = PHY_ADVERTISE_100_HALF | 39777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PHY_ADVERTISE_100_FULL; 39877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_100; 39977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 40077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 40177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_100 + HALF_DUPLEX: 402453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 403453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Forcing to 100 Mbps Half Duplex\n"); 40477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 0; 40577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = 0; 40677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_100; 40777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_HALF; 40877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 40977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_100 + FULL_DUPLEX: 410453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 411453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Forcing to 100 Mbps Full Duplex\n"); 41277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 0; 41377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = 0; 41477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_100; 41577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_FULL; 41677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 41777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_1000: 418453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 419453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "1000 Mbps Speed specified without Duplex\n"); 42077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake goto full_duplex_only; 42177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_1000 + HALF_DUPLEX: 422453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 423453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Half Duplex is not supported at 1000 Mbps\n"); 42477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake /* fall through */ 42577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake case SPEED_1000 + FULL_DUPLEX: 42677555ee7228234257957fd54daa0b69178906320Masayuki Ohtakefull_duplex_only: 427453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko netdev_dbg(adapter->netdev, 428453ca931f515161902dbb325d7f39a992c3059ceAndy Shevchenko "Using Autonegotiation at 1000 Mbps Full Duplex only\n"); 42977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.autoneg = hw->mac.fc_autoneg = 1; 43077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->phy.autoneg_advertised = PHY_ADVERTISE_1000_FULL; 43177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_speed = SPEED_1000; 43277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake hw->mac.link_duplex = DUPLEX_FULL; 43377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake break; 43477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake default: 43577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake BUG(); 43677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 43777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake} 43877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 43977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake/** 44077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * pch_gbe_check_options - Range Checking for Command Line Parameters 44177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake * @adapter: Board private structure 44277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake */ 44377555ee7228234257957fd54daa0b69178906320Masayuki Ohtakevoid pch_gbe_check_options(struct pch_gbe_adapter *adapter) 44477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake{ 44577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct pch_gbe_hw *hw = &adapter->hw; 446756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław struct net_device *dev = adapter->netdev; 447756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław int val; 44877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 44977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Transmit Descriptor Count */ 45077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 45177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = range_option, 45277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Transmit Descriptors", 45377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "using default of " 45477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake __MODULE_STRING(PCH_GBE_DEFAULT_TXD), 45577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_GBE_DEFAULT_TXD, 45650a4205333c5e545551f1f82b3004ca635407c5cToshiharu Okada .arg = { .r = { .min = PCH_GBE_MIN_TXD, 45750a4205333c5e545551f1f82b3004ca635407c5cToshiharu Okada .max = PCH_GBE_MAX_TXD } } 45877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 45977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring; 46077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake tx_ring->count = TxDescriptors; 46177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake pch_gbe_validate_option(&tx_ring->count, &opt, adapter); 46277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake tx_ring->count = roundup(tx_ring->count, 46377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PCH_GBE_TX_DESC_MULTIPLE); 46477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 46577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Receive Descriptor Count */ 46677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 46777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = range_option, 46877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Receive Descriptors", 46977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "using default of " 47077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake __MODULE_STRING(PCH_GBE_DEFAULT_RXD), 47177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_GBE_DEFAULT_RXD, 47250a4205333c5e545551f1f82b3004ca635407c5cToshiharu Okada .arg = { .r = { .min = PCH_GBE_MIN_RXD, 47350a4205333c5e545551f1f82b3004ca635407c5cToshiharu Okada .max = PCH_GBE_MAX_RXD } } 47477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 47577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring; 47677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake rx_ring->count = RxDescriptors; 47777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake pch_gbe_validate_option(&rx_ring->count, &opt, adapter); 47877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake rx_ring->count = roundup(rx_ring->count, 47977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake PCH_GBE_RX_DESC_MULTIPLE); 48077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 48177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Checksum Offload Enable/Disable */ 48277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 48377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = enable_option, 48477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Checksum Offload", 48577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "defaulting to Enabled", 48677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_GBE_DEFAULT_RX_CSUM 48777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 488756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław val = XsumRX; 489756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław pch_gbe_validate_option(&val, &opt, adapter); 490756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław if (!val) 491756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław dev->features &= ~NETIF_F_RXCSUM; 49277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 49377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Checksum Offload Enable/Disable */ 49477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 49577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = enable_option, 49677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Checksum Offload", 49777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "defaulting to Enabled", 49877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_GBE_DEFAULT_TX_CSUM 49977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 500756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław val = XsumTX; 501756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław pch_gbe_validate_option(&val, &opt, adapter); 502756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław if (!val) 503756a6b03da98903fa22ad7f10752de11782249fcMichał Mirosław dev->features &= ~NETIF_F_ALL_CSUM; 50477555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 50577555ee7228234257957fd54daa0b69178906320Masayuki Ohtake { /* Flow Control */ 50677555ee7228234257957fd54daa0b69178906320Masayuki Ohtake static const struct pch_gbe_option opt = { 50777555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .type = list_option, 50877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .name = "Flow Control", 50977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .err = "reading default settings from EEPROM", 51077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .def = PCH_GBE_FC_DEFAULT, 51177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .arg = { .l = { .nr = (int)ARRAY_SIZE(fc_list), 51277555ee7228234257957fd54daa0b69178906320Masayuki Ohtake .p = fc_list } } 51377555ee7228234257957fd54daa0b69178906320Masayuki Ohtake }; 51473f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter int tmp = FlowControl; 51573f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter 51673f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter pch_gbe_validate_option(&tmp, &opt, adapter); 51773f98eab9b9e0bab492ca06add5657d9e702ddb1Dan Carpenter hw->mac.fc = tmp; 51877555ee7228234257957fd54daa0b69178906320Masayuki Ohtake } 51977555ee7228234257957fd54daa0b69178906320Masayuki Ohtake 52077555ee7228234257957fd54daa0b69178906320Masayuki Ohtake pch_gbe_check_copper_options(adapter); 52177555ee7228234257957fd54daa0b69178906320Masayuki Ohtake} 522