···309309 Cfg9346 = 0x50,310310 Config0 = 0x51,311311 Config1 = 0x52,312312- FlashReg = 0x54,312312+ TimerInt = 0x54,313313 MediaStatus = 0x58,314314 Config3 = 0x59,315315 Config4 = 0x5A, /* absent on RTL-8139A */···325325 FIFOTMS = 0x70, /* FIFO Control and test. */326326 CSCR = 0x74, /* Chip Status and Configuration Register. */327327 PARA78 = 0x78,328328+ FlashReg = 0xD4, /* Communication with Flash ROM, four bytes. */328329 PARA7c = 0x7c, /* Magic transceiver parameter register. */329330 Config5 = 0xD8, /* absent on RTL-8139A */330331};
+3
drivers/net/Kconfig
···20572057 tristate "Realtek 8169 gigabit ethernet support"20582058 depends on PCI20592059 select CRC3220602060+ select MII20602061 ---help---20612062 Say Y here if you have a Realtek 8169 PCI Gigabit Ethernet adapter.20622063···24122411 tristate "Intel(R) 10GbE PCI Express adapters support"24132412 depends on PCI && INET24142413 select INET_LRO24142414+ select INTEL_IOATDMA24152415 ---help---24162416 This driver supports Intel(R) 10GbE PCI Express family of24172417 adapters. For more information on how to identify your adapter, go···24642462 select FW_LOADER24652463 select CRC3224662464 select INET_LRO24652465+ select INTEL_IOATDMA24672466 ---help---24682467 This driver supports Myricom Myri-10G Dual Protocol interface in24692468 Ethernet mode. If the eeprom on your board is not recent enough,
+9-9
drivers/net/arcnet/arcnet.c
···442442 BUGMSG(D_NORMAL, "WARNING! Station address FF may confuse "443443 "DOS networking programs!\n");444444445445- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);445445+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);446446 if (ASTATUS() & RESETflag) {447447- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);447447+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);448448 ACOMMAND(CFLAGScmd | RESETclear);449449 }450450451451452452- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);452452+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);453453 /* make sure we're ready to receive IRQ's. */454454 AINTMASK(0);455455 udelay(1); /* give it time to set the mask before456456 * we reset it again. (may not even be457457 * necessary)458458 */459459- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);459459+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);460460 lp->intmask = NORXflag | RECONflag;461461 AINTMASK(lp->intmask);462462- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);462462+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);463463464464 netif_start_queue(dev);465465···670670 freeskb = 0;671671 }672672673673- BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__FUNCTION__,ASTATUS());673673+ BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());674674 /* make sure we didn't ignore a TX IRQ while we were in here */675675 AINTMASK(0);676676677677- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);677677+ BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);678678 lp->intmask |= TXFREEflag|EXCNAKflag;679679 AINTMASK(lp->intmask);680680- BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__FUNCTION__,ASTATUS());680680+ BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());681681682682 spin_unlock_irqrestore(&lp->lock, flags);683683 if (freeskb) {···798798 diagstatus = (status >> 8) & 0xFF;799799800800 BUGMSG(D_DEBUG, "%s: %d: %s: status=%x\n",801801- __FILE__,__LINE__,__FUNCTION__,status);801801+ __FILE__,__LINE__,__func__,status);802802 didsomething = 0;803803804804 /*
···23902390 }2391239123922392 /* Init GPHY as early as possible due to power saving issue */23932393- spin_lock(&adapter->mdio_lock);23942393 atl1e_phy_init(&adapter->hw);23952395- spin_unlock(&adapter->mdio_lock);23962394 /* reset the controller to23972395 * put the device in a known good starting state */23982396 err = atl1e_reset_hw(&adapter->hw);
+2-1
drivers/net/au1000_eth.c
···653653654654 aup = dev->priv;655655656656+ spin_lock_init(&aup->lock);657657+656658 /* Allocate the data buffers */657659 /* Snooping works fine with eth on all au1xxx */658660 aup->vaddr = (u32)dma_alloc_noncoherent(NULL, MAX_BUF_SIZE *···755753 aup->tx_db_inuse[i] = pDB;756754 }757755758758- spin_lock_init(&aup->lock);759756 dev->base_addr = base;760757 dev->irq = irq;761758 dev->open = au1000_open;
···11/*******************************************************************************2233 Intel 10 Gigabit PCI Express Linux driver44- Copyright(c) 1999 - 2007 Intel Corporation.44+ Copyright(c) 1999 - 2008 Intel Corporation.5566 This program is free software; you can redistribute it and/or modify it77 under the terms and conditions of the GNU General Public License,···2020 the file called "COPYING".21212222 Contact Information:2323- Linux NICS <linux.nics@intel.com>2423 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>2524 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-64972625···4041#include <linux/dca.h>4142#endif42434343-#define IXGBE_ERR(args...) printk(KERN_ERR "ixgbe: " args)4444-4544#define PFX "ixgbe: "4645#define DPRINTK(nlevel, klevel, fmt, args...) \4746 ((void)((NETIF_MSG_##nlevel & adapter->msg_enable) && \4847 printk(KERN_##klevel PFX "%s: %s: " fmt, adapter->netdev->name, \4949- __FUNCTION__ , ## args)))4848+ __func__ , ## args)))50495150/* TX/RX descriptor defines */5251#define IXGBE_DEFAULT_TXD 1024···5457#define IXGBE_DEFAULT_RXD 10245558#define IXGBE_MAX_RXD 40965659#define IXGBE_MIN_RXD 645757-5858-#define IXGBE_DEFAULT_RXQ 15959-#define IXGBE_MAX_RXQ 16060-#define IXGBE_MIN_RXQ 16161-6262-#define IXGBE_DEFAULT_ITR_RX_USECS 125 /* 8k irqs/sec */6363-#define IXGBE_DEFAULT_ITR_TX_USECS 250 /* 4k irqs/sec */6464-#define IXGBE_MIN_ITR_USECS 100 /* 500k irqs/sec */6565-#define IXGBE_MAX_ITR_USECS 10000 /* 100 irqs/sec */66606761/* flow control */6862#define IXGBE_DEFAULT_FCRTL 0x10000···7587#define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_25676887789#define MAXIMUM_ETHERNET_VLAN_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)7878-7979-/* How many Tx Descriptors do we need to call netif_wake_queue? */8080-#define IXGBE_TX_QUEUE_WAKE 1681908291/* How many Rx Buffers do we bundle into one write to the hardware ? */8392#define IXGBE_RX_BUFFER_WRITE 16 /* Must be power of 2 */···104119 dma_addr_t dma;105120 struct page *page;106121 dma_addr_t page_dma;122122+ unsigned int page_offset;107123};108124109125struct ixgbe_queue_stats {···143157 struct net_lro_mgr lro_mgr;144158 bool lro_used;145159 struct ixgbe_queue_stats stats;146146- u8 v_idx; /* maps directly to the index for this ring in the hardware147147- * vector array, can also be used for finding the bit in EICR148148- * and friends that represents the vector for this ring */160160+ u16 v_idx; /* maps directly to the index for this ring in the hardware161161+ * vector array, can also be used for finding the bit in EICR162162+ * and friends that represents the vector for this ring */149163150150- u32 eims_value;151151- u16 itr_register;152164153153- char name[IFNAMSIZ + 5];154165 u16 work_limit; /* max work per interrupt */155166 u16 rx_buf_len;156167};···174191 DECLARE_BITMAP(txr_idx, MAX_TX_QUEUES); /* Tx ring indices */175192 u8 rxr_count; /* Rx ring count assigned to this vector */176193 u8 txr_count; /* Tx ring count assigned to this vector */177177- u8 tx_eitr;178178- u8 rx_eitr;194194+ u8 tx_itr;195195+ u8 rx_itr;179196 u32 eitr;180197};181198···223240224241 /* TX */225242 struct ixgbe_ring *tx_ring; /* One per active queue */243243+ int num_tx_queues;226244 u64 restart_queue;245245+ u64 hw_csum_tx_good;227246 u64 lsc_int;228247 u64 hw_tso_ctxt;229248 u64 hw_tso6_ctxt;···234249235250 /* RX */236251 struct ixgbe_ring *rx_ring; /* One per active queue */237237- u64 hw_csum_tx_good;252252+ int num_rx_queues;238253 u64 hw_csum_rx_error;239254 u64 hw_csum_rx_good;240255 u64 non_eop_descs;241241- int num_tx_queues;242242- int num_rx_queues;243256 int num_msix_vectors;244257 struct ixgbe_ring_feature ring_feature[3];245258 struct msix_entry *msix_entries;···284301 struct ixgbe_hw_stats stats;285302286303 /* Interrupt Throttle Rate */287287- u32 rx_eitr;288288- u32 tx_eitr;304304+ u32 eitr_param;289305290306 unsigned long state;291307 u64 tx_busy;292308 u64 lro_aggregated;293309 u64 lro_flushed;294310 u64 lro_no_desc;311311+ unsigned int tx_ring_count;312312+ unsigned int rx_ring_count;313313+314314+ u32 link_speed;315315+ bool link_up;316316+ unsigned long link_check_timeout;317317+318318+ struct work_struct watchdog_task;295319};296320297321enum ixbge_state_t {···320330extern void ixgbe_down(struct ixgbe_adapter *adapter);321331extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);322332extern void ixgbe_reset(struct ixgbe_adapter *adapter);323323-extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);324333extern void ixgbe_set_ethtool_ops(struct net_device *netdev);325325-extern int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,326326- struct ixgbe_ring *rxdr);327327-extern int ixgbe_setup_tx_resources(struct ixgbe_adapter *adapter,328328- struct ixgbe_ring *txdr);334334+extern int ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);335335+extern int ixgbe_setup_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);336336+extern void ixgbe_free_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);337337+extern void ixgbe_free_tx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);338338+extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);329339330340#endif /* _IXGBE_H_ */
+517-107
drivers/net/ixgbe/ixgbe_82598.c
···11/*******************************************************************************2233 Intel 10 Gigabit PCI Express Linux driver44- Copyright(c) 1999 - 2007 Intel Corporation.44+ Copyright(c) 1999 - 2008 Intel Corporation.5566 This program is free software; you can redistribute it and/or modify it77 under the terms and conditions of the GNU General Public License,···2020 the file called "COPYING".21212222 Contact Information:2323- Linux NICS <linux.nics@intel.com>2423 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>2524 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-64972625···3839#define IXGBE_82598_MC_TBL_SIZE 1283940#define IXGBE_82598_VFT_TBL_SIZE 12840414141-static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw);4242-static s32 ixgbe_get_link_settings_82598(struct ixgbe_hw *hw, u32 *speed,4343- bool *autoneg);4444-static s32 ixgbe_get_copper_link_settings_82598(struct ixgbe_hw *hw,4545- u32 *speed, bool *autoneg);4646-static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw);4747-static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw);4848-static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, u32 *speed,4949- bool *link_up);5050-static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw, u32 speed,5151- bool autoneg,5252- bool autoneg_wait_to_complete);4242+static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,4343+ ixgbe_link_speed *speed,4444+ bool *autoneg);5345static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw);5454-static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed,5555- bool autoneg,5656- bool autoneg_wait_to_complete);5757-static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw);4646+static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,4747+ ixgbe_link_speed speed,4848+ bool autoneg,4949+ bool autoneg_wait_to_complete);58505959-5151+/**5252+ */6053static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)6154{6262- hw->mac.num_rx_queues = IXGBE_82598_MAX_RX_QUEUES;6363- hw->mac.num_tx_queues = IXGBE_82598_MAX_TX_QUEUES;6464- hw->mac.mcft_size = IXGBE_82598_MC_TBL_SIZE;6565- hw->mac.vft_size = IXGBE_82598_VFT_TBL_SIZE;6666- hw->mac.num_rar_entries = IXGBE_82598_RAR_ENTRIES;5555+ struct ixgbe_mac_info *mac = &hw->mac;5656+ struct ixgbe_phy_info *phy = &hw->phy;67576868- /* PHY ops are filled in by default properly for Fiber only */6969- if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {7070- hw->mac.ops.setup_link = &ixgbe_setup_copper_link_82598;7171- hw->mac.ops.setup_link_speed = &ixgbe_setup_copper_link_speed_82598;7272- hw->mac.ops.get_link_settings =7373- &ixgbe_get_copper_link_settings_82598;5858+ /* Call PHY identify routine to get the phy type */5959+ ixgbe_identify_phy_generic(hw);74607575- /* Call PHY identify routine to get the phy type */7676- ixgbe_identify_phy(hw);7777-7878- switch (hw->phy.type) {7979- case ixgbe_phy_tn:8080- hw->phy.ops.setup_link = &ixgbe_setup_tnx_phy_link;8181- hw->phy.ops.check_link = &ixgbe_check_tnx_phy_link;8282- hw->phy.ops.setup_link_speed =8383- &ixgbe_setup_tnx_phy_link_speed;8484- break;8585- default:8686- break;8787- }6161+ /* PHY Init */6262+ switch (phy->type) {6363+ default:6464+ break;8865 }6666+6767+ if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {6868+ mac->ops.setup_link = &ixgbe_setup_copper_link_82598;6969+ mac->ops.setup_link_speed =7070+ &ixgbe_setup_copper_link_speed_82598;7171+ mac->ops.get_link_capabilities =7272+ &ixgbe_get_copper_link_capabilities_82598;7373+ }7474+7575+ mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;7676+ mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;7777+ mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;7878+ mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;7979+ mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;89809081 return 0;9182}92839384/**9494- * ixgbe_get_link_settings_82598 - Determines default link settings8585+ * ixgbe_get_link_capabilities_82598 - Determines link capabilities9586 * @hw: pointer to hardware structure9687 * @speed: pointer to link speed9788 * @autoneg: boolean auto-negotiation value9889 *9999- * Determines the default link settings by reading the AUTOC register.9090+ * Determines the link capabilities by reading the AUTOC register.10091 **/101101-static s32 ixgbe_get_link_settings_82598(struct ixgbe_hw *hw, u32 *speed,102102- bool *autoneg)9292+static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,9393+ ixgbe_link_speed *speed,9494+ bool *autoneg)10395{10496 s32 status = 0;10597 s32 autoc_reg;···139149}140150141151/**142142- * ixgbe_get_copper_link_settings_82598 - Determines default link settings152152+ * ixgbe_get_copper_link_capabilities_82598 - Determines link capabilities143153 * @hw: pointer to hardware structure144154 * @speed: pointer to link speed145155 * @autoneg: boolean auto-negotiation value146156 *147147- * Determines the default link settings by reading the AUTOC register.157157+ * Determines the link capabilities by reading the AUTOC register.148158 **/149149-static s32 ixgbe_get_copper_link_settings_82598(struct ixgbe_hw *hw,150150- u32 *speed, bool *autoneg)159159+s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,160160+ ixgbe_link_speed *speed,161161+ bool *autoneg)151162{152163 s32 status = IXGBE_ERR_LINK_SETUP;153164 u16 speed_ability;···156165 *speed = 0;157166 *autoneg = true;158167159159- status = ixgbe_read_phy_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,160160- IXGBE_MDIO_PMA_PMD_DEV_TYPE,161161- &speed_ability);168168+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,169169+ IXGBE_MDIO_PMA_PMD_DEV_TYPE,170170+ &speed_ability);162171163172 if (status == 0) {164173 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)···186195 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:187196 case IXGBE_DEV_ID_82598EB_CX4:188197 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:198198+ case IXGBE_DEV_ID_82598EB_XF_LR:189199 media_type = ixgbe_media_type_fiber;190190- break;191191- case IXGBE_DEV_ID_82598AT_DUAL_PORT:192192- media_type = ixgbe_media_type_copper;193200 break;194201 default:195202 media_type = ixgbe_media_type_unknown;···195206 }196207197208 return media_type;209209+}210210+211211+/**212212+ * ixgbe_setup_fc_82598 - Configure flow control settings213213+ * @hw: pointer to hardware structure214214+ * @packetbuf_num: packet buffer number (0-7)215215+ *216216+ * Configures the flow control settings based on SW configuration. This217217+ * function is used for 802.3x flow control configuration only.218218+ **/219219+s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)220220+{221221+ u32 frctl_reg;222222+ u32 rmcs_reg;223223+224224+ if (packetbuf_num < 0 || packetbuf_num > 7) {225225+ hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"226226+ " 0-7\n", packetbuf_num);227227+ }228228+229229+ frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);230230+ frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);231231+232232+ rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);233233+ rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);234234+235235+ /*236236+ * 10 gig parts do not have a word in the EEPROM to determine the237237+ * default flow control setting, so we explicitly set it to full.238238+ */239239+ if (hw->fc.type == ixgbe_fc_default)240240+ hw->fc.type = ixgbe_fc_full;241241+242242+ /*243243+ * We want to save off the original Flow Control configuration just in244244+ * case we get disconnected and then reconnected into a different hub245245+ * or switch with different Flow Control capabilities.246246+ */247247+ hw->fc.original_type = hw->fc.type;248248+249249+ /*250250+ * The possible values of the "flow_control" parameter are:251251+ * 0: Flow control is completely disabled252252+ * 1: Rx flow control is enabled (we can receive pause frames but not253253+ * send pause frames).254254+ * 2: Tx flow control is enabled (we can send pause frames but we do not255255+ * support receiving pause frames)256256+ * 3: Both Rx and Tx flow control (symmetric) are enabled.257257+ * other: Invalid.258258+ */259259+ switch (hw->fc.type) {260260+ case ixgbe_fc_none:261261+ break;262262+ case ixgbe_fc_rx_pause:263263+ /*264264+ * Rx Flow control is enabled,265265+ * and Tx Flow control is disabled.266266+ */267267+ frctl_reg |= IXGBE_FCTRL_RFCE;268268+ break;269269+ case ixgbe_fc_tx_pause:270270+ /*271271+ * Tx Flow control is enabled, and Rx Flow control is disabled,272272+ * by a software over-ride.273273+ */274274+ rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;275275+ break;276276+ case ixgbe_fc_full:277277+ /*278278+ * Flow control (both Rx and Tx) is enabled by a software279279+ * over-ride.280280+ */281281+ frctl_reg |= IXGBE_FCTRL_RFCE;282282+ rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;283283+ break;284284+ default:285285+ /* We should never get here. The value should be 0-3. */286286+ hw_dbg(hw, "Flow control param set incorrectly\n");287287+ break;288288+ }289289+290290+ /* Enable 802.3x based flow control settings. */291291+ IXGBE_WRITE_REG(hw, IXGBE_FCTRL, frctl_reg);292292+ IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);293293+294294+ /*295295+ * Check for invalid software configuration, zeros are completely296296+ * invalid for all parameters used past this point, and if we enable297297+ * flow control with zero water marks, we blast flow control packets.298298+ */299299+ if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {300300+ hw_dbg(hw, "Flow control structure initialized incorrectly\n");301301+ return IXGBE_ERR_INVALID_LINK_SETTINGS;302302+ }303303+304304+ /*305305+ * We need to set up the Receive Threshold high and low water306306+ * marks as well as (optionally) enabling the transmission of307307+ * XON frames.308308+ */309309+ if (hw->fc.type & ixgbe_fc_tx_pause) {310310+ if (hw->fc.send_xon) {311311+ IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),312312+ (hw->fc.low_water | IXGBE_FCRTL_XONE));313313+ } else {314314+ IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),315315+ hw->fc.low_water);316316+ }317317+ IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),318318+ (hw->fc.high_water)|IXGBE_FCRTH_FCEN);319319+ }320320+321321+ IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time);322322+ IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1));323323+324324+ return 0;198325}199326200327/**···357252 }358253 if (!(links_reg & IXGBE_LINKS_KX_AN_COMP)) {359254 status = IXGBE_ERR_AUTONEG_NOT_COMPLETE;360360- hw_dbg(hw,361361- "Autonegotiation did not complete.\n");255255+ hw_dbg(hw, "Autonegotiation did not complete.\n");362256 }363257 }364258 }···367263 * case we get disconnected and then reconnected into a different hub368264 * or switch with different Flow Control capabilities.369265 */370370- hw->fc.type = hw->fc.original_type;371371- ixgbe_setup_fc(hw, 0);266266+ hw->fc.original_type = hw->fc.type;267267+ ixgbe_setup_fc_82598(hw, 0);372268373269 /* Add delay to filter out noises during initial link setup */374270 msleep(50);···381277 * @hw: pointer to hardware structure382278 * @speed: pointer to link speed383279 * @link_up: true is link is up, false otherwise280280+ * @link_up_wait_to_complete: bool used to wait for link up or not384281 *385282 * Reads the links register to determine if link is up and the current speed386283 **/387387-static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, u32 *speed,388388- bool *link_up)284284+static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,285285+ ixgbe_link_speed *speed, bool *link_up,286286+ bool link_up_wait_to_complete)389287{390288 u32 links_reg;289289+ u32 i;391290392291 links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);393393-394394- if (links_reg & IXGBE_LINKS_UP)395395- *link_up = true;396396- else397397- *link_up = false;292292+ if (link_up_wait_to_complete) {293293+ for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {294294+ if (links_reg & IXGBE_LINKS_UP) {295295+ *link_up = true;296296+ break;297297+ } else {298298+ *link_up = false;299299+ }300300+ msleep(100);301301+ links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);302302+ }303303+ } else {304304+ if (links_reg & IXGBE_LINKS_UP)305305+ *link_up = true;306306+ else307307+ *link_up = false;308308+ }398309399310 if (links_reg & IXGBE_LINKS_SPEED)400311 *speed = IXGBE_LINK_SPEED_10GB_FULL;···418299419300 return 0;420301}302302+421303422304/**423305 * ixgbe_setup_mac_link_speed_82598 - Set MAC link speed···430310 * Set the link speed in the AUTOC register and restarts link.431311 **/432312static s32 ixgbe_setup_mac_link_speed_82598(struct ixgbe_hw *hw,433433- u32 speed, bool autoneg,434434- bool autoneg_wait_to_complete)313313+ ixgbe_link_speed speed, bool autoneg,314314+ bool autoneg_wait_to_complete)435315{436316 s32 status = 0;437317438318 /* If speed is 10G, then check for CX4 or XAUI. */439319 if ((speed == IXGBE_LINK_SPEED_10GB_FULL) &&440440- (!(hw->mac.link_attach_type & IXGBE_AUTOC_10G_KX4)))320320+ (!(hw->mac.link_attach_type & IXGBE_AUTOC_10G_KX4))) {441321 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN;442442- else if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && (!autoneg))322322+ } else if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && (!autoneg)) {443323 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_LINK_NO_AN;444444- else if (autoneg) {324324+ } else if (autoneg) {445325 /* BX mode - Autonegotiate 1G */446326 if (!(hw->mac.link_attach_type & IXGBE_AUTOC_1G_PMA_PMD))447327 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_1G_AN;···460340 * ixgbe_hw This will write the AUTOC register based on the new461341 * stored values462342 */463463- hw->mac.ops.setup_link(hw);343343+ ixgbe_setup_mac_link_82598(hw);464344 }465345466346 return status;···478358 **/479359static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw)480360{481481- s32 status = 0;361361+ s32 status;482362483363 /* Restart autonegotiation on PHY */484484- if (hw->phy.ops.setup_link)485485- status = hw->phy.ops.setup_link(hw);364364+ status = hw->phy.ops.setup_link(hw);486365487487- /* Set MAC to KX/KX4 autoneg, which defaultis to Parallel detection */366366+ /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */488367 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);489368 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;490369491370 /* Set up MAC */492492- hw->mac.ops.setup_link(hw);371371+ ixgbe_setup_mac_link_82598(hw);493372494373 return status;495374}···502383 *503384 * Sets the link speed in the AUTOC register in the MAC and restarts link.504385 **/505505-static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw, u32 speed,506506- bool autoneg,507507- bool autoneg_wait_to_complete)386386+static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,387387+ ixgbe_link_speed speed,388388+ bool autoneg,389389+ bool autoneg_wait_to_complete)508390{509509- s32 status = 0;391391+ s32 status;510392511393 /* Setup the PHY according to input speed */512512- if (hw->phy.ops.setup_link_speed)513513- status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,514514- autoneg_wait_to_complete);394394+ status = hw->phy.ops.setup_link_speed(hw, speed, autoneg,395395+ autoneg_wait_to_complete);515396516397 /* Set MAC to KX/KX4 autoneg, which defaults to Parallel detection */517398 hw->mac.link_attach_type = (IXGBE_AUTOC_10G_KX4 | IXGBE_AUTOC_1G_KX);518399 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_KX4_AN;519400520401 /* Set up MAC */521521- hw->mac.ops.setup_link(hw);402402+ ixgbe_setup_mac_link_82598(hw);522403523404 return status;524405}···527408 * ixgbe_reset_hw_82598 - Performs hardware reset528409 * @hw: pointer to hardware structure529410 *530530- * Resets the hardware by reseting the transmit and receive units, masks and411411+ * Resets the hardware by resetting the transmit and receive units, masks and531412 * clears all interrupts, performing a PHY reset, and performing a link (MAC)532413 * reset.533414 **/···541422 u8 analog_val;542423543424 /* Call adapter stop to disable tx/rx and clear interrupts */544544- ixgbe_stop_adapter(hw);425425+ hw->mac.ops.stop_adapter(hw);545426546427 /*547547- * Power up the Atlas TX lanes if they are currently powered down.548548- * Atlas TX lanes are powered down for MAC loopback tests, but428428+ * Power up the Atlas Tx lanes if they are currently powered down.429429+ * Atlas Tx lanes are powered down for MAC loopback tests, but549430 * they are not automatically restored on reset.550431 */551551- ixgbe_read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);432432+ hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);552433 if (analog_val & IXGBE_ATLAS_PDN_TX_REG_EN) {553553- /* Enable TX Atlas so packets can be transmitted again */554554- ixgbe_read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, &analog_val);434434+ /* Enable Tx Atlas so packets can be transmitted again */435435+ hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,436436+ &analog_val);555437 analog_val &= ~IXGBE_ATLAS_PDN_TX_REG_EN;556556- ixgbe_write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK, analog_val);438438+ hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_LPBK,439439+ analog_val);557440558558- ixgbe_read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, &analog_val);441441+ hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,442442+ &analog_val);559443 analog_val &= ~IXGBE_ATLAS_PDN_TX_10G_QL_ALL;560560- ixgbe_write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G, analog_val);444444+ hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_10G,445445+ analog_val);561446562562- ixgbe_read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, &analog_val);447447+ hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,448448+ &analog_val);563449 analog_val &= ~IXGBE_ATLAS_PDN_TX_1G_QL_ALL;564564- ixgbe_write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G, analog_val);450450+ hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_1G,451451+ analog_val);565452566566- ixgbe_read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, &analog_val);453453+ hw->mac.ops.read_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,454454+ &analog_val);567455 analog_val &= ~IXGBE_ATLAS_PDN_TX_AN_QL_ALL;568568- ixgbe_write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN, analog_val);456456+ hw->mac.ops.write_analog_reg8(hw, IXGBE_ATLAS_PDN_AN,457457+ analog_val);569458 }570459571460 /* Reset PHY */572572- ixgbe_reset_phy(hw);461461+ if (hw->phy.reset_disable == false)462462+ hw->phy.ops.reset(hw);573463574464 /*575465 * Prevent the PCI-E bus from from hanging by disabling PCI-E master···631503 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);632504 } else {633505 hw->mac.link_attach_type =634634- (autoc & IXGBE_AUTOC_LMS_ATTACH_TYPE);506506+ (autoc & IXGBE_AUTOC_LMS_ATTACH_TYPE);635507 hw->mac.link_mode_select = (autoc & IXGBE_AUTOC_LMS_MASK);636508 hw->mac.link_settings_loaded = true;637509 }638510639511 /* Store the permanent mac address */640640- ixgbe_get_mac_addr(hw, hw->mac.perm_addr);512512+ hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);641513642514 return status;643515}644516517517+/**518518+ * ixgbe_set_vmdq_82598 - Associate a VMDq set index with a rx address519519+ * @hw: pointer to hardware struct520520+ * @rar: receive address register index to associate with a VMDq index521521+ * @vmdq: VMDq set index522522+ **/523523+s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)524524+{525525+ u32 rar_high;526526+527527+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));528528+ rar_high &= ~IXGBE_RAH_VIND_MASK;529529+ rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);530530+ IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);531531+ return 0;532532+}533533+534534+/**535535+ * ixgbe_clear_vmdq_82598 - Disassociate a VMDq set index from an rx address536536+ * @hw: pointer to hardware struct537537+ * @rar: receive address register index to associate with a VMDq index538538+ * @vmdq: VMDq clear index (not used in 82598, but elsewhere)539539+ **/540540+static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)541541+{542542+ u32 rar_high;543543+ u32 rar_entries = hw->mac.num_rar_entries;544544+545545+ if (rar < rar_entries) {546546+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));547547+ if (rar_high & IXGBE_RAH_VIND_MASK) {548548+ rar_high &= ~IXGBE_RAH_VIND_MASK;549549+ IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);550550+ }551551+ } else {552552+ hw_dbg(hw, "RAR index %d is out of range.\n", rar);553553+ }554554+555555+ return 0;556556+}557557+558558+/**559559+ * ixgbe_set_vfta_82598 - Set VLAN filter table560560+ * @hw: pointer to hardware structure561561+ * @vlan: VLAN id to write to VLAN filter562562+ * @vind: VMDq output index that maps queue to VLAN id in VFTA563563+ * @vlan_on: boolean flag to turn on/off VLAN in VFTA564564+ *565565+ * Turn on/off specified VLAN in the VLAN filter table.566566+ **/567567+s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,568568+ bool vlan_on)569569+{570570+ u32 regindex;571571+ u32 bitindex;572572+ u32 bits;573573+ u32 vftabyte;574574+575575+ if (vlan > 4095)576576+ return IXGBE_ERR_PARAM;577577+578578+ /* Determine 32-bit word position in array */579579+ regindex = (vlan >> 5) & 0x7F; /* upper seven bits */580580+581581+ /* Determine the location of the (VMD) queue index */582582+ vftabyte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */583583+ bitindex = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */584584+585585+ /* Set the nibble for VMD queue index */586586+ bits = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex));587587+ bits &= (~(0x0F << bitindex));588588+ bits |= (vind << bitindex);589589+ IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vftabyte, regindex), bits);590590+591591+ /* Determine the location of the bit for this VLAN id */592592+ bitindex = vlan & 0x1F; /* lower five bits */593593+594594+ bits = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));595595+ if (vlan_on)596596+ /* Turn on this VLAN id */597597+ bits |= (1 << bitindex);598598+ else599599+ /* Turn off this VLAN id */600600+ bits &= ~(1 << bitindex);601601+ IXGBE_WRITE_REG(hw, IXGBE_VFTA(regindex), bits);602602+603603+ return 0;604604+}605605+606606+/**607607+ * ixgbe_clear_vfta_82598 - Clear VLAN filter table608608+ * @hw: pointer to hardware structure609609+ *610610+ * Clears the VLAN filer table, and the VMDq index associated with the filter611611+ **/612612+static s32 ixgbe_clear_vfta_82598(struct ixgbe_hw *hw)613613+{614614+ u32 offset;615615+ u32 vlanbyte;616616+617617+ for (offset = 0; offset < hw->mac.vft_size; offset++)618618+ IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);619619+620620+ for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)621621+ for (offset = 0; offset < hw->mac.vft_size; offset++)622622+ IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),623623+ 0);624624+625625+ return 0;626626+}627627+628628+/**629629+ * ixgbe_blink_led_start_82598 - Blink LED based on index.630630+ * @hw: pointer to hardware structure631631+ * @index: led number to blink632632+ **/633633+static s32 ixgbe_blink_led_start_82598(struct ixgbe_hw *hw, u32 index)634634+{635635+ ixgbe_link_speed speed = 0;636636+ bool link_up = 0;637637+ u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);638638+ u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);639639+640640+ /*641641+ * Link must be up to auto-blink the LEDs on the 82598EB MAC;642642+ * force it if link is down.643643+ */644644+ hw->mac.ops.check_link(hw, &speed, &link_up, false);645645+646646+ if (!link_up) {647647+ autoc_reg |= IXGBE_AUTOC_FLU;648648+ IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);649649+ msleep(10);650650+ }651651+652652+ led_reg &= ~IXGBE_LED_MODE_MASK(index);653653+ led_reg |= IXGBE_LED_BLINK(index);654654+ IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);655655+ IXGBE_WRITE_FLUSH(hw);656656+657657+ return 0;658658+}659659+660660+/**661661+ * ixgbe_blink_led_stop_82598 - Stop blinking LED based on index.662662+ * @hw: pointer to hardware structure663663+ * @index: led number to stop blinking664664+ **/665665+static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index)666666+{667667+ u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);668668+ u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);669669+670670+ autoc_reg &= ~IXGBE_AUTOC_FLU;671671+ autoc_reg |= IXGBE_AUTOC_AN_RESTART;672672+ IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg);673673+674674+ led_reg &= ~IXGBE_LED_MODE_MASK(index);675675+ led_reg &= ~IXGBE_LED_BLINK(index);676676+ led_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);677677+ IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, led_reg);678678+ IXGBE_WRITE_FLUSH(hw);679679+680680+ return 0;681681+}682682+683683+/**684684+ * ixgbe_read_analog_reg8_82598 - Reads 8 bit Atlas analog register685685+ * @hw: pointer to hardware structure686686+ * @reg: analog register to read687687+ * @val: read value688688+ *689689+ * Performs read operation to Atlas analog register specified.690690+ **/691691+s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)692692+{693693+ u32 atlas_ctl;694694+695695+ IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,696696+ IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));697697+ IXGBE_WRITE_FLUSH(hw);698698+ udelay(10);699699+ atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);700700+ *val = (u8)atlas_ctl;701701+702702+ return 0;703703+}704704+705705+/**706706+ * ixgbe_write_analog_reg8_82598 - Writes 8 bit Atlas analog register707707+ * @hw: pointer to hardware structure708708+ * @reg: atlas register to write709709+ * @val: value to write710710+ *711711+ * Performs write operation to Atlas analog register specified.712712+ **/713713+s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)714714+{715715+ u32 atlas_ctl;716716+717717+ atlas_ctl = (reg << 8) | val;718718+ IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);719719+ IXGBE_WRITE_FLUSH(hw);720720+ udelay(10);721721+722722+ return 0;723723+}724724+725725+/**726726+ * ixgbe_get_supported_physical_layer_82598 - Returns physical layer type727727+ * @hw: pointer to hardware structure728728+ *729729+ * Determines physical layer capabilities of the current configuration.730730+ **/731731+s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)732732+{733733+ s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;734734+735735+ switch (hw->device_id) {736736+ case IXGBE_DEV_ID_82598EB_CX4:737737+ case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:738738+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;739739+ break;740740+ case IXGBE_DEV_ID_82598AF_DUAL_PORT:741741+ case IXGBE_DEV_ID_82598AF_SINGLE_PORT:742742+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;743743+ break;744744+ case IXGBE_DEV_ID_82598EB_XF_LR:745745+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;746746+ break;747747+748748+ default:749749+ physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;750750+ break;751751+ }752752+753753+ return physical_layer;754754+}755755+645756static struct ixgbe_mac_operations mac_ops_82598 = {646646- .reset = &ixgbe_reset_hw_82598,757757+ .init_hw = &ixgbe_init_hw_generic,758758+ .reset_hw = &ixgbe_reset_hw_82598,759759+ .start_hw = &ixgbe_start_hw_generic,760760+ .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,647761 .get_media_type = &ixgbe_get_media_type_82598,762762+ .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,763763+ .get_mac_addr = &ixgbe_get_mac_addr_generic,764764+ .stop_adapter = &ixgbe_stop_adapter_generic,765765+ .read_analog_reg8 = &ixgbe_read_analog_reg8_82598,766766+ .write_analog_reg8 = &ixgbe_write_analog_reg8_82598,648767 .setup_link = &ixgbe_setup_mac_link_82598,649649- .check_link = &ixgbe_check_mac_link_82598,650768 .setup_link_speed = &ixgbe_setup_mac_link_speed_82598,651651- .get_link_settings = &ixgbe_get_link_settings_82598,769769+ .check_link = &ixgbe_check_mac_link_82598,770770+ .get_link_capabilities = &ixgbe_get_link_capabilities_82598,771771+ .led_on = &ixgbe_led_on_generic,772772+ .led_off = &ixgbe_led_off_generic,773773+ .blink_led_start = &ixgbe_blink_led_start_82598,774774+ .blink_led_stop = &ixgbe_blink_led_stop_82598,775775+ .set_rar = &ixgbe_set_rar_generic,776776+ .clear_rar = &ixgbe_clear_rar_generic,777777+ .set_vmdq = &ixgbe_set_vmdq_82598,778778+ .clear_vmdq = &ixgbe_clear_vmdq_82598,779779+ .init_rx_addrs = &ixgbe_init_rx_addrs_generic,780780+ .update_uc_addr_list = &ixgbe_update_uc_addr_list_generic,781781+ .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic,782782+ .enable_mc = &ixgbe_enable_mc_generic,783783+ .disable_mc = &ixgbe_disable_mc_generic,784784+ .clear_vfta = &ixgbe_clear_vfta_82598,785785+ .set_vfta = &ixgbe_set_vfta_82598,786786+ .setup_fc = &ixgbe_setup_fc_82598,787787+};788788+789789+static struct ixgbe_eeprom_operations eeprom_ops_82598 = {790790+ .init_params = &ixgbe_init_eeprom_params_generic,791791+ .read = &ixgbe_read_eeprom_generic,792792+ .validate_checksum = &ixgbe_validate_eeprom_checksum_generic,793793+ .update_checksum = &ixgbe_update_eeprom_checksum_generic,794794+};795795+796796+static struct ixgbe_phy_operations phy_ops_82598 = {797797+ .identify = &ixgbe_identify_phy_generic,798798+ /* .identify_sfp = &ixgbe_identify_sfp_module_generic, */799799+ .reset = &ixgbe_reset_phy_generic,800800+ .read_reg = &ixgbe_read_phy_reg_generic,801801+ .write_reg = &ixgbe_write_phy_reg_generic,802802+ .setup_link = &ixgbe_setup_phy_link_generic,803803+ .setup_link_speed = &ixgbe_setup_phy_link_speed_generic,652804};653805654806struct ixgbe_info ixgbe_82598_info = {655807 .mac = ixgbe_mac_82598EB,656808 .get_invariants = &ixgbe_get_invariants_82598,657809 .mac_ops = &mac_ops_82598,810810+ .eeprom_ops = &eeprom_ops_82598,811811+ .phy_ops = &phy_ops_82598,658812};659813
+637-335
drivers/net/ixgbe/ixgbe_common.c
···11/*******************************************************************************2233 Intel 10 Gigabit PCI Express Linux driver44- Copyright(c) 1999 - 2007 Intel Corporation.44+ Copyright(c) 1999 - 2008 Intel Corporation.5566 This program is free software; you can redistribute it and/or modify it77 under the terms and conditions of the GNU General Public License,···2020 the file called "COPYING".21212222 Contact Information:2323- Linux NICS <linux.nics@intel.com>2423 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>2524 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-64972625···3233#include "ixgbe_common.h"3334#include "ixgbe_phy.h"34353535-static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw);3636-3736static s32 ixgbe_poll_eeprom_eerd_done(struct ixgbe_hw *hw);3737+static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw);3838static s32 ixgbe_get_eeprom_semaphore(struct ixgbe_hw *hw);3939static void ixgbe_release_eeprom_semaphore(struct ixgbe_hw *hw);4040+static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw);4141+static void ixgbe_standby_eeprom(struct ixgbe_hw *hw);4242+static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data,4343+ u16 count);4444+static u16 ixgbe_shift_in_eeprom_bits(struct ixgbe_hw *hw, u16 count);4545+static void ixgbe_raise_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);4646+static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);4747+static void ixgbe_release_eeprom(struct ixgbe_hw *hw);4048static u16 ixgbe_calc_eeprom_checksum(struct ixgbe_hw *hw);41494242-static s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);4343-static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw);5050+static void ixgbe_enable_rar(struct ixgbe_hw *hw, u32 index);5151+static void ixgbe_disable_rar(struct ixgbe_hw *hw, u32 index);4452static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr);4553static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr);5454+static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq);46554756/**4848- * ixgbe_start_hw - Prepare hardware for TX/RX5757+ * ixgbe_start_hw_generic - Prepare hardware for Tx/Rx4958 * @hw: pointer to hardware structure5059 *5160 * Starts the hardware by filling the bus info structure and media type, clears···6154 * table, VLAN filter table, calls routine to set up link and flow control6255 * settings, and leaves transmit and receive units disabled and uninitialized6356 **/6464-s32 ixgbe_start_hw(struct ixgbe_hw *hw)5757+s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)6558{6659 u32 ctrl_ext;6760···6962 hw->phy.media_type = hw->mac.ops.get_media_type(hw);70637164 /* Identify the PHY */7272- ixgbe_identify_phy(hw);6565+ hw->phy.ops.identify(hw);73667467 /*7568 * Store MAC address from RAR0, clear receive address registers, and7669 * clear the multicast table7770 */7878- ixgbe_init_rx_addrs(hw);7171+ hw->mac.ops.init_rx_addrs(hw);79728073 /* Clear the VLAN filter table */8181- ixgbe_clear_vfta(hw);7474+ hw->mac.ops.clear_vfta(hw);82758376 /* Set up link */8477 hw->mac.ops.setup_link(hw);85788679 /* Clear statistics registers */8787- ixgbe_clear_hw_cntrs(hw);8080+ hw->mac.ops.clear_hw_cntrs(hw);88818982 /* Set No Snoop Disable */9083 ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);···9992}1009310194/**102102- * ixgbe_init_hw - Generic hardware initialization9595+ * ixgbe_init_hw_generic - Generic hardware initialization10396 * @hw: pointer to hardware structure10497 *105105- * Initialize the hardware by reseting the hardware, filling the bus info9898+ * Initialize the hardware by resetting the hardware, filling the bus info10699 * structure and media type, clears all on chip counters, initializes receive107100 * address registers, multicast table, VLAN filter table, calls routine to set108101 * up link and flow control settings, and leaves transmit and receive units109102 * disabled and uninitialized110103 **/111111-s32 ixgbe_init_hw(struct ixgbe_hw *hw)104104+s32 ixgbe_init_hw_generic(struct ixgbe_hw *hw)112105{113106 /* Reset the hardware */114114- hw->mac.ops.reset(hw);107107+ hw->mac.ops.reset_hw(hw);115108116109 /* Start the HW */117117- ixgbe_start_hw(hw);110110+ hw->mac.ops.start_hw(hw);118111119112 return 0;120113}121114122115/**123123- * ixgbe_clear_hw_cntrs - Generic clear hardware counters116116+ * ixgbe_clear_hw_cntrs_generic - Generic clear hardware counters124117 * @hw: pointer to hardware structure125118 *126119 * Clears all hardware statistics counters by reading them from the hardware127120 * Statistics counters are clear on read.128121 **/129129-static s32 ixgbe_clear_hw_cntrs(struct ixgbe_hw *hw)122122+s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw)130123{131124 u16 i = 0;132125···198191}199192200193/**201201- * ixgbe_get_mac_addr - Generic get MAC address194194+ * ixgbe_read_pba_num_generic - Reads part number from EEPROM195195+ * @hw: pointer to hardware structure196196+ * @pba_num: stores the part number from the EEPROM197197+ *198198+ * Reads the part number from the EEPROM.199199+ **/200200+s32 ixgbe_read_pba_num_generic(struct ixgbe_hw *hw, u32 *pba_num)201201+{202202+ s32 ret_val;203203+ u16 data;204204+205205+ ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM0_PTR, &data);206206+ if (ret_val) {207207+ hw_dbg(hw, "NVM Read Error\n");208208+ return ret_val;209209+ }210210+ *pba_num = (u32)(data << 16);211211+212212+ ret_val = hw->eeprom.ops.read(hw, IXGBE_PBANUM1_PTR, &data);213213+ if (ret_val) {214214+ hw_dbg(hw, "NVM Read Error\n");215215+ return ret_val;216216+ }217217+ *pba_num |= data;218218+219219+ return 0;220220+}221221+222222+/**223223+ * ixgbe_get_mac_addr_generic - Generic get MAC address202224 * @hw: pointer to hardware structure203225 * @mac_addr: Adapter MAC address204226 *···235199 * A reset of the adapter must be performed prior to calling this function236200 * in order for the MAC address to have been loaded from the EEPROM into RAR0237201 **/238238-s32 ixgbe_get_mac_addr(struct ixgbe_hw *hw, u8 *mac_addr)202202+s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr)239203{240204 u32 rar_high;241205 u32 rar_low;···253217 return 0;254218}255219256256-s32 ixgbe_read_part_num(struct ixgbe_hw *hw, u32 *part_num)257257-{258258- s32 ret_val;259259- u16 data;260260-261261- ret_val = ixgbe_read_eeprom(hw, IXGBE_PBANUM0_PTR, &data);262262- if (ret_val) {263263- hw_dbg(hw, "NVM Read Error\n");264264- return ret_val;265265- }266266- *part_num = (u32)(data << 16);267267-268268- ret_val = ixgbe_read_eeprom(hw, IXGBE_PBANUM1_PTR, &data);269269- if (ret_val) {270270- hw_dbg(hw, "NVM Read Error\n");271271- return ret_val;272272- }273273- *part_num |= data;274274-275275- return 0;276276-}277277-278220/**279279- * ixgbe_stop_adapter - Generic stop TX/RX units221221+ * ixgbe_stop_adapter_generic - Generic stop Tx/Rx units280222 * @hw: pointer to hardware structure281223 *282224 * Sets the adapter_stopped flag within ixgbe_hw struct. Clears interrupts,···262248 * the shared code and drivers to determine if the adapter is in a stopped263249 * state and should not touch the hardware.264250 **/265265-s32 ixgbe_stop_adapter(struct ixgbe_hw *hw)251251+s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw)266252{267253 u32 number_of_queues;268254 u32 reg_val;···278264 reg_val = IXGBE_READ_REG(hw, IXGBE_RXCTRL);279265 reg_val &= ~(IXGBE_RXCTRL_RXEN);280266 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, reg_val);267267+ IXGBE_WRITE_FLUSH(hw);281268 msleep(2);282269283270 /* Clear interrupt mask to stop from interrupts being generated */···288273 IXGBE_READ_REG(hw, IXGBE_EICR);289274290275 /* Disable the transmit unit. Each queue must be disabled. */291291- number_of_queues = hw->mac.num_tx_queues;276276+ number_of_queues = hw->mac.max_tx_queues;292277 for (i = 0; i < number_of_queues; i++) {293278 reg_val = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));294279 if (reg_val & IXGBE_TXDCTL_ENABLE) {···297282 }298283 }299284285285+ /*286286+ * Prevent the PCI-E bus from from hanging by disabling PCI-E master287287+ * access and verify no pending requests288288+ */289289+ if (ixgbe_disable_pcie_master(hw) != 0)290290+ hw_dbg(hw, "PCI-E Master disable polling has failed.\n");291291+300292 return 0;301293}302294303295/**304304- * ixgbe_led_on - Turns on the software controllable LEDs.296296+ * ixgbe_led_on_generic - Turns on the software controllable LEDs.305297 * @hw: pointer to hardware structure306298 * @index: led number to turn on307299 **/308308-s32 ixgbe_led_on(struct ixgbe_hw *hw, u32 index)300300+s32 ixgbe_led_on_generic(struct ixgbe_hw *hw, u32 index)309301{310302 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);311303···326304}327305328306/**329329- * ixgbe_led_off - Turns off the software controllable LEDs.307307+ * ixgbe_led_off_generic - Turns off the software controllable LEDs.330308 * @hw: pointer to hardware structure331309 * @index: led number to turn off332310 **/333333-s32 ixgbe_led_off(struct ixgbe_hw *hw, u32 index)311311+s32 ixgbe_led_off_generic(struct ixgbe_hw *hw, u32 index)334312{335313 u32 led_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);336314···343321 return 0;344322}345323346346-347324/**348348- * ixgbe_init_eeprom - Initialize EEPROM params325325+ * ixgbe_init_eeprom_params_generic - Initialize EEPROM params349326 * @hw: pointer to hardware structure350327 *351328 * Initializes the EEPROM parameters ixgbe_eeprom_info within the352329 * ixgbe_hw struct in order to set up EEPROM access.353330 **/354354-s32 ixgbe_init_eeprom(struct ixgbe_hw *hw)331331+s32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw)355332{356333 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;357334 u32 eec;···358337359338 if (eeprom->type == ixgbe_eeprom_uninitialized) {360339 eeprom->type = ixgbe_eeprom_none;340340+ /* Set default semaphore delay to 10ms which is a well341341+ * tested value */342342+ eeprom->semaphore_delay = 10;361343362344 /*363345 * Check for EEPROM present first.···393369}394370395371/**396396- * ixgbe_read_eeprom - Read EEPROM word using EERD372372+ * ixgbe_read_eeprom_bit_bang_generic - Read EEPROM word using bit-bang373373+ * @hw: pointer to hardware structure374374+ * @offset: offset within the EEPROM to be read375375+ * @data: read 16 bit value from EEPROM376376+ *377377+ * Reads 16 bit value from EEPROM through bit-bang method378378+ **/379379+s32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,380380+ u16 *data)381381+{382382+ s32 status;383383+ u16 word_in;384384+ u8 read_opcode = IXGBE_EEPROM_READ_OPCODE_SPI;385385+386386+ hw->eeprom.ops.init_params(hw);387387+388388+ if (offset >= hw->eeprom.word_size) {389389+ status = IXGBE_ERR_EEPROM;390390+ goto out;391391+ }392392+393393+ /* Prepare the EEPROM for reading */394394+ status = ixgbe_acquire_eeprom(hw);395395+396396+ if (status == 0) {397397+ if (ixgbe_ready_eeprom(hw) != 0) {398398+ ixgbe_release_eeprom(hw);399399+ status = IXGBE_ERR_EEPROM;400400+ }401401+ }402402+403403+ if (status == 0) {404404+ ixgbe_standby_eeprom(hw);405405+406406+ /*407407+ * Some SPI eeproms use the 8th address bit embedded in the408408+ * opcode409409+ */410410+ if ((hw->eeprom.address_bits == 8) && (offset >= 128))411411+ read_opcode |= IXGBE_EEPROM_A8_OPCODE_SPI;412412+413413+ /* Send the READ command (opcode + addr) */414414+ ixgbe_shift_out_eeprom_bits(hw, read_opcode,415415+ IXGBE_EEPROM_OPCODE_BITS);416416+ ixgbe_shift_out_eeprom_bits(hw, (u16)(offset*2),417417+ hw->eeprom.address_bits);418418+419419+ /* Read the data. */420420+ word_in = ixgbe_shift_in_eeprom_bits(hw, 16);421421+ *data = (word_in >> 8) | (word_in << 8);422422+423423+ /* End this read operation */424424+ ixgbe_release_eeprom(hw);425425+ }426426+427427+out:428428+ return status;429429+}430430+431431+/**432432+ * ixgbe_read_eeprom_generic - Read EEPROM word using EERD397433 * @hw: pointer to hardware structure398434 * @offset: offset of word in the EEPROM to read399435 * @data: word read from the EEPROM400436 *401437 * Reads a 16 bit word from the EEPROM using the EERD register.402438 **/403403-s32 ixgbe_read_eeprom(struct ixgbe_hw *hw, u16 offset, u16 *data)439439+s32 ixgbe_read_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 *data)404440{405441 u32 eerd;406442 s32 status;443443+444444+ hw->eeprom.ops.init_params(hw);445445+446446+ if (offset >= hw->eeprom.word_size) {447447+ status = IXGBE_ERR_EEPROM;448448+ goto out;449449+ }407450408451 eerd = (offset << IXGBE_EEPROM_READ_ADDR_SHIFT) +409452 IXGBE_EEPROM_READ_REG_START;···480389481390 if (status == 0)482391 *data = (IXGBE_READ_REG(hw, IXGBE_EERD) >>483483- IXGBE_EEPROM_READ_REG_DATA);392392+ IXGBE_EEPROM_READ_REG_DATA);484393 else485394 hw_dbg(hw, "Eeprom read timed out\n");486395396396+out:487397 return status;488398}489399···507415 break;508416 }509417 udelay(5);418418+ }419419+ return status;420420+}421421+422422+/**423423+ * ixgbe_acquire_eeprom - Acquire EEPROM using bit-bang424424+ * @hw: pointer to hardware structure425425+ *426426+ * Prepares EEPROM for access using bit-bang method. This function should427427+ * be called before issuing a command to the EEPROM.428428+ **/429429+static s32 ixgbe_acquire_eeprom(struct ixgbe_hw *hw)430430+{431431+ s32 status = 0;432432+ u32 eec;433433+ u32 i;434434+435435+ if (ixgbe_acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) != 0)436436+ status = IXGBE_ERR_SWFW_SYNC;437437+438438+ if (status == 0) {439439+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);440440+441441+ /* Request EEPROM Access */442442+ eec |= IXGBE_EEC_REQ;443443+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);444444+445445+ for (i = 0; i < IXGBE_EEPROM_GRANT_ATTEMPTS; i++) {446446+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);447447+ if (eec & IXGBE_EEC_GNT)448448+ break;449449+ udelay(5);450450+ }451451+452452+ /* Release if grant not acquired */453453+ if (!(eec & IXGBE_EEC_GNT)) {454454+ eec &= ~IXGBE_EEC_REQ;455455+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);456456+ hw_dbg(hw, "Could not acquire EEPROM grant\n");457457+458458+ ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);459459+ status = IXGBE_ERR_EEPROM;460460+ }461461+ }462462+463463+ /* Setup EEPROM for Read/Write */464464+ if (status == 0) {465465+ /* Clear CS and SK */466466+ eec &= ~(IXGBE_EEC_CS | IXGBE_EEC_SK);467467+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);468468+ IXGBE_WRITE_FLUSH(hw);469469+ udelay(1);510470 }511471 return status;512472}···619475 */620476 if (i >= timeout) {621477 hw_dbg(hw, "Driver can't access the Eeprom - Semaphore "622622- "not granted.\n");478478+ "not granted.\n");623479 ixgbe_release_eeprom_semaphore(hw);624480 status = IXGBE_ERR_EEPROM;625481 }···647503}648504649505/**506506+ * ixgbe_ready_eeprom - Polls for EEPROM ready507507+ * @hw: pointer to hardware structure508508+ **/509509+static s32 ixgbe_ready_eeprom(struct ixgbe_hw *hw)510510+{511511+ s32 status = 0;512512+ u16 i;513513+ u8 spi_stat_reg;514514+515515+ /*516516+ * Read "Status Register" repeatedly until the LSB is cleared. The517517+ * EEPROM will signal that the command has been completed by clearing518518+ * bit 0 of the internal status register. If it's not cleared within519519+ * 5 milliseconds, then error out.520520+ */521521+ for (i = 0; i < IXGBE_EEPROM_MAX_RETRY_SPI; i += 5) {522522+ ixgbe_shift_out_eeprom_bits(hw, IXGBE_EEPROM_RDSR_OPCODE_SPI,523523+ IXGBE_EEPROM_OPCODE_BITS);524524+ spi_stat_reg = (u8)ixgbe_shift_in_eeprom_bits(hw, 8);525525+ if (!(spi_stat_reg & IXGBE_EEPROM_STATUS_RDY_SPI))526526+ break;527527+528528+ udelay(5);529529+ ixgbe_standby_eeprom(hw);530530+ };531531+532532+ /*533533+ * On some parts, SPI write time could vary from 0-20mSec on 3.3V534534+ * devices (and only 0-5mSec on 5V devices)535535+ */536536+ if (i >= IXGBE_EEPROM_MAX_RETRY_SPI) {537537+ hw_dbg(hw, "SPI EEPROM Status error\n");538538+ status = IXGBE_ERR_EEPROM;539539+ }540540+541541+ return status;542542+}543543+544544+/**545545+ * ixgbe_standby_eeprom - Returns EEPROM to a "standby" state546546+ * @hw: pointer to hardware structure547547+ **/548548+static void ixgbe_standby_eeprom(struct ixgbe_hw *hw)549549+{550550+ u32 eec;551551+552552+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);553553+554554+ /* Toggle CS to flush commands */555555+ eec |= IXGBE_EEC_CS;556556+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);557557+ IXGBE_WRITE_FLUSH(hw);558558+ udelay(1);559559+ eec &= ~IXGBE_EEC_CS;560560+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);561561+ IXGBE_WRITE_FLUSH(hw);562562+ udelay(1);563563+}564564+565565+/**566566+ * ixgbe_shift_out_eeprom_bits - Shift data bits out to the EEPROM.567567+ * @hw: pointer to hardware structure568568+ * @data: data to send to the EEPROM569569+ * @count: number of bits to shift out570570+ **/571571+static void ixgbe_shift_out_eeprom_bits(struct ixgbe_hw *hw, u16 data,572572+ u16 count)573573+{574574+ u32 eec;575575+ u32 mask;576576+ u32 i;577577+578578+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);579579+580580+ /*581581+ * Mask is used to shift "count" bits of "data" out to the EEPROM582582+ * one bit at a time. Determine the starting bit based on count583583+ */584584+ mask = 0x01 << (count - 1);585585+586586+ for (i = 0; i < count; i++) {587587+ /*588588+ * A "1" is shifted out to the EEPROM by setting bit "DI" to a589589+ * "1", and then raising and then lowering the clock (the SK590590+ * bit controls the clock input to the EEPROM). A "0" is591591+ * shifted out to the EEPROM by setting "DI" to "0" and then592592+ * raising and then lowering the clock.593593+ */594594+ if (data & mask)595595+ eec |= IXGBE_EEC_DI;596596+ else597597+ eec &= ~IXGBE_EEC_DI;598598+599599+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);600600+ IXGBE_WRITE_FLUSH(hw);601601+602602+ udelay(1);603603+604604+ ixgbe_raise_eeprom_clk(hw, &eec);605605+ ixgbe_lower_eeprom_clk(hw, &eec);606606+607607+ /*608608+ * Shift mask to signify next bit of data to shift in to the609609+ * EEPROM610610+ */611611+ mask = mask >> 1;612612+ };613613+614614+ /* We leave the "DI" bit set to "0" when we leave this routine. */615615+ eec &= ~IXGBE_EEC_DI;616616+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);617617+ IXGBE_WRITE_FLUSH(hw);618618+}619619+620620+/**621621+ * ixgbe_shift_in_eeprom_bits - Shift data bits in from the EEPROM622622+ * @hw: pointer to hardware structure623623+ **/624624+static u16 ixgbe_shift_in_eeprom_bits(struct ixgbe_hw *hw, u16 count)625625+{626626+ u32 eec;627627+ u32 i;628628+ u16 data = 0;629629+630630+ /*631631+ * In order to read a register from the EEPROM, we need to shift632632+ * 'count' bits in from the EEPROM. Bits are "shifted in" by raising633633+ * the clock input to the EEPROM (setting the SK bit), and then reading634634+ * the value of the "DO" bit. During this "shifting in" process the635635+ * "DI" bit should always be clear.636636+ */637637+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);638638+639639+ eec &= ~(IXGBE_EEC_DO | IXGBE_EEC_DI);640640+641641+ for (i = 0; i < count; i++) {642642+ data = data << 1;643643+ ixgbe_raise_eeprom_clk(hw, &eec);644644+645645+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);646646+647647+ eec &= ~(IXGBE_EEC_DI);648648+ if (eec & IXGBE_EEC_DO)649649+ data |= 1;650650+651651+ ixgbe_lower_eeprom_clk(hw, &eec);652652+ }653653+654654+ return data;655655+}656656+657657+/**658658+ * ixgbe_raise_eeprom_clk - Raises the EEPROM's clock input.659659+ * @hw: pointer to hardware structure660660+ * @eec: EEC register's current value661661+ **/662662+static void ixgbe_raise_eeprom_clk(struct ixgbe_hw *hw, u32 *eec)663663+{664664+ /*665665+ * Raise the clock input to the EEPROM666666+ * (setting the SK bit), then delay667667+ */668668+ *eec = *eec | IXGBE_EEC_SK;669669+ IXGBE_WRITE_REG(hw, IXGBE_EEC, *eec);670670+ IXGBE_WRITE_FLUSH(hw);671671+ udelay(1);672672+}673673+674674+/**675675+ * ixgbe_lower_eeprom_clk - Lowers the EEPROM's clock input.676676+ * @hw: pointer to hardware structure677677+ * @eecd: EECD's current value678678+ **/679679+static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec)680680+{681681+ /*682682+ * Lower the clock input to the EEPROM (clearing the SK bit), then683683+ * delay684684+ */685685+ *eec = *eec & ~IXGBE_EEC_SK;686686+ IXGBE_WRITE_REG(hw, IXGBE_EEC, *eec);687687+ IXGBE_WRITE_FLUSH(hw);688688+ udelay(1);689689+}690690+691691+/**692692+ * ixgbe_release_eeprom - Release EEPROM, release semaphores693693+ * @hw: pointer to hardware structure694694+ **/695695+static void ixgbe_release_eeprom(struct ixgbe_hw *hw)696696+{697697+ u32 eec;698698+699699+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);700700+701701+ eec |= IXGBE_EEC_CS; /* Pull CS high */702702+ eec &= ~IXGBE_EEC_SK; /* Lower SCK */703703+704704+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);705705+ IXGBE_WRITE_FLUSH(hw);706706+707707+ udelay(1);708708+709709+ /* Stop requesting EEPROM access */710710+ eec &= ~IXGBE_EEC_REQ;711711+ IXGBE_WRITE_REG(hw, IXGBE_EEC, eec);712712+713713+ ixgbe_release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);714714+}715715+716716+/**650717 * ixgbe_calc_eeprom_checksum - Calculates and returns the checksum651718 * @hw: pointer to hardware structure652719 **/···872517873518 /* Include 0x0-0x3F in the checksum */874519 for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {875875- if (ixgbe_read_eeprom(hw, i, &word) != 0) {520520+ if (hw->eeprom.ops.read(hw, i, &word) != 0) {876521 hw_dbg(hw, "EEPROM read failed\n");877522 break;878523 }···881526882527 /* Include all data from pointers except for the fw pointer */883528 for (i = IXGBE_PCIE_ANALOG_PTR; i < IXGBE_FW_PTR; i++) {884884- ixgbe_read_eeprom(hw, i, &pointer);529529+ hw->eeprom.ops.read(hw, i, &pointer);885530886531 /* Make sure the pointer seems valid */887532 if (pointer != 0xFFFF && pointer != 0) {888888- ixgbe_read_eeprom(hw, pointer, &length);533533+ hw->eeprom.ops.read(hw, pointer, &length);889534890535 if (length != 0xFFFF && length != 0) {891536 for (j = pointer+1; j <= pointer+length; j++) {892892- ixgbe_read_eeprom(hw, j, &word);537537+ hw->eeprom.ops.read(hw, j, &word);893538 checksum += word;894539 }895540 }···902547}903548904549/**905905- * ixgbe_validate_eeprom_checksum - Validate EEPROM checksum550550+ * ixgbe_validate_eeprom_checksum_generic - Validate EEPROM checksum906551 * @hw: pointer to hardware structure907552 * @checksum_val: calculated checksum908553 *909554 * Performs checksum calculation and validates the EEPROM checksum. If the910555 * caller does not need checksum_val, the value can be NULL.911556 **/912912-s32 ixgbe_validate_eeprom_checksum(struct ixgbe_hw *hw, u16 *checksum_val)557557+s32 ixgbe_validate_eeprom_checksum_generic(struct ixgbe_hw *hw,558558+ u16 *checksum_val)913559{914560 s32 status;915561 u16 checksum;···921565 * not continue or we could be in for a very long wait while every922566 * EEPROM read fails923567 */924924- status = ixgbe_read_eeprom(hw, 0, &checksum);568568+ status = hw->eeprom.ops.read(hw, 0, &checksum);925569926570 if (status == 0) {927571 checksum = ixgbe_calc_eeprom_checksum(hw);928572929929- ixgbe_read_eeprom(hw, IXGBE_EEPROM_CHECKSUM, &read_checksum);573573+ hw->eeprom.ops.read(hw, IXGBE_EEPROM_CHECKSUM, &read_checksum);930574931575 /*932576 * Verify read checksum from EEPROM is the same as···938582 /* If the user cares, return the calculated checksum */939583 if (checksum_val)940584 *checksum_val = checksum;585585+ } else {586586+ hw_dbg(hw, "EEPROM read failed\n");587587+ }588588+589589+ return status;590590+}591591+592592+/**593593+ * ixgbe_update_eeprom_checksum_generic - Updates the EEPROM checksum594594+ * @hw: pointer to hardware structure595595+ **/596596+s32 ixgbe_update_eeprom_checksum_generic(struct ixgbe_hw *hw)597597+{598598+ s32 status;599599+ u16 checksum;600600+601601+ /*602602+ * Read the first word from the EEPROM. If this times out or fails, do603603+ * not continue or we could be in for a very long wait while every604604+ * EEPROM read fails605605+ */606606+ status = hw->eeprom.ops.read(hw, 0, &checksum);607607+608608+ if (status == 0) {609609+ checksum = ixgbe_calc_eeprom_checksum(hw);610610+ status = hw->eeprom.ops.write(hw, IXGBE_EEPROM_CHECKSUM,611611+ checksum);941612 } else {942613 hw_dbg(hw, "EEPROM read failed\n");943614 }···990607 status = IXGBE_ERR_INVALID_MAC_ADDR;991608 /* Reject the zero address */992609 else if (mac_addr[0] == 0 && mac_addr[1] == 0 && mac_addr[2] == 0 &&993993- mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)610610+ mac_addr[3] == 0 && mac_addr[4] == 0 && mac_addr[5] == 0)994611 status = IXGBE_ERR_INVALID_MAC_ADDR;995612996613 return status;997614}998615999616/**10001000- * ixgbe_set_rar - Set RX address register617617+ * ixgbe_set_rar_generic - Set Rx address register1001618 * @hw: pointer to hardware structure10021002- * @addr: Address to put into receive address register1003619 * @index: Receive address register to write10041004- * @vind: Vind to set RAR to620620+ * @addr: Address to put into receive address register621621+ * @vmdq: VMDq "set" or "pool" index1005622 * @enable_addr: set flag that address is active1006623 *1007624 * Puts an ethernet address into a receive address register.1008625 **/10091009-s32 ixgbe_set_rar(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vind,10101010- u32 enable_addr)626626+s32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,627627+ u32 enable_addr)1011628{1012629 u32 rar_low, rar_high;630630+ u32 rar_entries = hw->mac.num_rar_entries;101363110141014- /*10151015- * HW expects these in little endian so we reverse the byte order from10161016- * network order (big endian) to little endian10171017- */10181018- rar_low = ((u32)addr[0] |10191019- ((u32)addr[1] << 8) |10201020- ((u32)addr[2] << 16) |10211021- ((u32)addr[3] << 24));632632+ /* setup VMDq pool selection before this RAR gets enabled */633633+ hw->mac.ops.set_vmdq(hw, index, vmdq);102263410231023- rar_high = ((u32)addr[4] |10241024- ((u32)addr[5] << 8) |10251025- ((vind << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK));635635+ /* Make sure we are using a valid rar index range */636636+ if (index < rar_entries) {637637+ /*638638+ * HW expects these in little endian so we reverse the byte639639+ * order from network order (big endian) to little endian640640+ */641641+ rar_low = ((u32)addr[0] |642642+ ((u32)addr[1] << 8) |643643+ ((u32)addr[2] << 16) |644644+ ((u32)addr[3] << 24));645645+ /*646646+ * Some parts put the VMDq setting in the extra RAH bits,647647+ * so save everything except the lower 16 bits that hold part648648+ * of the address and the address valid bit.649649+ */650650+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));651651+ rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);652652+ rar_high |= ((u32)addr[4] | ((u32)addr[5] << 8));102665310271027- if (enable_addr != 0)10281028- rar_high |= IXGBE_RAH_AV;654654+ if (enable_addr != 0)655655+ rar_high |= IXGBE_RAH_AV;102965610301030- IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);10311031- IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);657657+ IXGBE_WRITE_REG(hw, IXGBE_RAL(index), rar_low);658658+ IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);659659+ } else {660660+ hw_dbg(hw, "RAR index %d is out of range.\n", index);661661+ }10326621033663 return 0;1034664}10356651036666/**10371037- * ixgbe_init_rx_addrs - Initializes receive address filters.667667+ * ixgbe_clear_rar_generic - Remove Rx address register668668+ * @hw: pointer to hardware structure669669+ * @index: Receive address register to write670670+ *671671+ * Clears an ethernet address from a receive address register.672672+ **/673673+s32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index)674674+{675675+ u32 rar_high;676676+ u32 rar_entries = hw->mac.num_rar_entries;677677+678678+ /* Make sure we are using a valid rar index range */679679+ if (index < rar_entries) {680680+ /*681681+ * Some parts put the VMDq setting in the extra RAH bits,682682+ * so save everything except the lower 16 bits that hold part683683+ * of the address and the address valid bit.684684+ */685685+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));686686+ rar_high &= ~(0x0000FFFF | IXGBE_RAH_AV);687687+688688+ IXGBE_WRITE_REG(hw, IXGBE_RAL(index), 0);689689+ IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);690690+ } else {691691+ hw_dbg(hw, "RAR index %d is out of range.\n", index);692692+ }693693+694694+ /* clear VMDq pool/queue selection for this RAR */695695+ hw->mac.ops.clear_vmdq(hw, index, IXGBE_CLEAR_VMDQ_ALL);696696+697697+ return 0;698698+}699699+700700+/**701701+ * ixgbe_enable_rar - Enable Rx address register702702+ * @hw: pointer to hardware structure703703+ * @index: index into the RAR table704704+ *705705+ * Enables the select receive address register.706706+ **/707707+static void ixgbe_enable_rar(struct ixgbe_hw *hw, u32 index)708708+{709709+ u32 rar_high;710710+711711+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));712712+ rar_high |= IXGBE_RAH_AV;713713+ IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);714714+}715715+716716+/**717717+ * ixgbe_disable_rar - Disable Rx address register718718+ * @hw: pointer to hardware structure719719+ * @index: index into the RAR table720720+ *721721+ * Disables the select receive address register.722722+ **/723723+static void ixgbe_disable_rar(struct ixgbe_hw *hw, u32 index)724724+{725725+ u32 rar_high;726726+727727+ rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(index));728728+ rar_high &= (~IXGBE_RAH_AV);729729+ IXGBE_WRITE_REG(hw, IXGBE_RAH(index), rar_high);730730+}731731+732732+/**733733+ * ixgbe_init_rx_addrs_generic - Initializes receive address filters.1038734 * @hw: pointer to hardware structure1039735 *1040736 * Places the MAC address in receive address register 0 and clears the rest10411041- * of the receive addresss registers. Clears the multicast table. Assumes737737+ * of the receive address registers. Clears the multicast table. Assumes1042738 * the receiver is in reset when the routine is called.1043739 **/10441044-static s32 ixgbe_init_rx_addrs(struct ixgbe_hw *hw)740740+s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw)1045741{1046742 u32 i;1047743 u32 rar_entries = hw->mac.num_rar_entries;···1133671 if (ixgbe_validate_mac_addr(hw->mac.addr) ==1134672 IXGBE_ERR_INVALID_MAC_ADDR) {1135673 /* Get the MAC address from the RAR0 for later reference */11361136- ixgbe_get_mac_addr(hw, hw->mac.addr);674674+ hw->mac.ops.get_mac_addr(hw, hw->mac.addr);11376751138676 hw_dbg(hw, " Keeping Current RAR0 Addr =%.2X %.2X %.2X ",11391139- hw->mac.addr[0], hw->mac.addr[1],11401140- hw->mac.addr[2]);677677+ hw->mac.addr[0], hw->mac.addr[1],678678+ hw->mac.addr[2]);1141679 hw_dbg(hw, "%.2X %.2X %.2X\n", hw->mac.addr[3],11421142- hw->mac.addr[4], hw->mac.addr[5]);680680+ hw->mac.addr[4], hw->mac.addr[5]);1143681 } else {1144682 /* Setup the receive address. */1145683 hw_dbg(hw, "Overriding MAC Address in RAR[0]\n");1146684 hw_dbg(hw, " New MAC Addr =%.2X %.2X %.2X ",11471147- hw->mac.addr[0], hw->mac.addr[1],11481148- hw->mac.addr[2]);685685+ hw->mac.addr[0], hw->mac.addr[1],686686+ hw->mac.addr[2]);1149687 hw_dbg(hw, "%.2X %.2X %.2X\n", hw->mac.addr[3],11501150- hw->mac.addr[4], hw->mac.addr[5]);688688+ hw->mac.addr[4], hw->mac.addr[5]);115168911521152- ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);690690+ hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);1153691 }692692+ hw->addr_ctrl.overflow_promisc = 0;11546931155694 hw->addr_ctrl.rar_used_count = 1;11566951157696 /* Zero out the other receive addresses. */11581158- hw_dbg(hw, "Clearing RAR[1-15]\n");697697+ hw_dbg(hw, "Clearing RAR[1-%d]\n", rar_entries - 1);1159698 for (i = 1; i < rar_entries; i++) {1160699 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);1161700 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);···1171708 for (i = 0; i < hw->mac.mcft_size; i++)1172709 IXGBE_WRITE_REG(hw, IXGBE_MTA(i), 0);1173710711711+ if (hw->mac.ops.init_uta_tables)712712+ hw->mac.ops.init_uta_tables(hw);713713+1174714 return 0;1175715}1176716···1184718 *1185719 * Adds it to unused receive address register or goes into promiscuous mode.1186720 **/11871187-void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr)721721+static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)1188722{1189723 u32 rar_entries = hw->mac.num_rar_entries;1190724 u32 rar;···1199733 if (hw->addr_ctrl.rar_used_count < rar_entries) {1200734 rar = hw->addr_ctrl.rar_used_count -1201735 hw->addr_ctrl.mc_addr_in_rar_count;12021202- ixgbe_set_rar(hw, rar, addr, 0, IXGBE_RAH_AV);736736+ hw->mac.ops.set_rar(hw, rar, addr, vmdq, IXGBE_RAH_AV);1203737 hw_dbg(hw, "Added a secondary address to RAR[%d]\n", rar);1204738 hw->addr_ctrl.rar_used_count++;1205739 } else {···1210744}12117451212746/**12131213- * ixgbe_update_uc_addr_list - Updates MAC list of secondary addresses747747+ * ixgbe_update_uc_addr_list_generic - Updates MAC list of secondary addresses1214748 * @hw: pointer to hardware structure1215749 * @addr_list: the list of new addresses1216750 * @addr_count: number of addresses···1223757 * Drivers using secondary unicast addresses must set user_set_promisc when1224758 * manually putting the device into promiscuous mode.1225759 **/12261226-s32 ixgbe_update_uc_addr_list(struct ixgbe_hw *hw, u8 *addr_list,760760+s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list,1227761 u32 addr_count, ixgbe_mc_addr_itr next)1228762{1229763 u8 *addr;···1253787 for (i = 0; i < addr_count; i++) {1254788 hw_dbg(hw, " Adding the secondary addresses:\n");1255789 addr = next(hw, &addr_list, &vmdq);12561256- ixgbe_add_uc_addr(hw, addr);790790+ ixgbe_add_uc_addr(hw, addr, vmdq);1257791 }12587921259793 if (hw->addr_ctrl.overflow_promisc) {···1274808 }1275809 }127681012771277- hw_dbg(hw, "ixgbe_update_uc_addr_list Complete\n");811811+ hw_dbg(hw, "ixgbe_update_uc_addr_list_generic Complete\n");1278812 return 0;1279813}1280814···1287821 * bit-vector to set in the multicast table. The hardware uses 12 bits, from1288822 * incoming rx multicast addresses, to determine the bit-vector to check in1289823 * the MTA. Which of the 4 combination, of 12-bits, the hardware uses is set12901290- * by the MO field of the MCSTCTRL. The MO field is set during initalization824824+ * by the MO field of the MCSTCTRL. The MO field is set during initialization1291825 * to mc_filter_type.1292826 **/1293827static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr)···1295829 u32 vector = 0;12968301297831 switch (hw->mac.mc_filter_type) {12981298- case 0: /* use bits [47:36] of the address */832832+ case 0: /* use bits [47:36] of the address */1299833 vector = ((mc_addr[4] >> 4) | (((u16)mc_addr[5]) << 4));1300834 break;13011301- case 1: /* use bits [46:35] of the address */835835+ case 1: /* use bits [46:35] of the address */1302836 vector = ((mc_addr[4] >> 3) | (((u16)mc_addr[5]) << 5));1303837 break;13041304- case 2: /* use bits [45:34] of the address */838838+ case 2: /* use bits [45:34] of the address */1305839 vector = ((mc_addr[4] >> 2) | (((u16)mc_addr[5]) << 6));1306840 break;13071307- case 3: /* use bits [43:32] of the address */841841+ case 3: /* use bits [43:32] of the address */1308842 vector = ((mc_addr[4]) | (((u16)mc_addr[5]) << 8));1309843 break;13101310- default: /* Invalid mc_filter_type */844844+ default: /* Invalid mc_filter_type */1311845 hw_dbg(hw, "MC filter type param set incorrectly\n");1312846 break;1313847 }···1362896static void ixgbe_add_mc_addr(struct ixgbe_hw *hw, u8 *mc_addr)1363897{1364898 u32 rar_entries = hw->mac.num_rar_entries;899899+ u32 rar;13659001366901 hw_dbg(hw, " MC Addr =%.2X %.2X %.2X %.2X %.2X %.2X\n",13671367- mc_addr[0], mc_addr[1], mc_addr[2],13681368- mc_addr[3], mc_addr[4], mc_addr[5]);902902+ mc_addr[0], mc_addr[1], mc_addr[2],903903+ mc_addr[3], mc_addr[4], mc_addr[5]);13699041370905 /*1371906 * Place this multicast address in the RAR if there is room,1372907 * else put it in the MTA1373908 */1374909 if (hw->addr_ctrl.rar_used_count < rar_entries) {13751375- ixgbe_set_rar(hw, hw->addr_ctrl.rar_used_count,13761376- mc_addr, 0, IXGBE_RAH_AV);13771377- hw_dbg(hw, "Added a multicast address to RAR[%d]\n",13781378- hw->addr_ctrl.rar_used_count);910910+ /* use RAR from the end up for multicast */911911+ rar = rar_entries - hw->addr_ctrl.mc_addr_in_rar_count - 1;912912+ hw->mac.ops.set_rar(hw, rar, mc_addr, 0, IXGBE_RAH_AV);913913+ hw_dbg(hw, "Added a multicast address to RAR[%d]\n", rar);1379914 hw->addr_ctrl.rar_used_count++;1380915 hw->addr_ctrl.mc_addr_in_rar_count++;1381916 } else {···1387920}13889211389922/**13901390- * ixgbe_update_mc_addr_list - Updates MAC list of multicast addresses923923+ * ixgbe_update_mc_addr_list_generic - Updates MAC list of multicast addresses1391924 * @hw: pointer to hardware structure1392925 * @mc_addr_list: the list of new multicast addresses1393926 * @mc_addr_count: number of addresses1394927 * @next: iterator function to walk the multicast address list1395928 *1396929 * The given list replaces any existing list. Clears the MC addrs from receive13971397- * address registers and the multicast table. Uses unsed receive address930930+ * address registers and the multicast table. Uses unused receive address1398931 * registers for the first multicast addresses, and hashes the rest into the1399932 * multicast table.1400933 **/14011401-s32 ixgbe_update_mc_addr_list(struct ixgbe_hw *hw, u8 *mc_addr_list,14021402- u32 mc_addr_count, ixgbe_mc_addr_itr next)934934+s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list,935935+ u32 mc_addr_count, ixgbe_mc_addr_itr next)1403936{1404937 u32 i;1405938 u32 rar_entries = hw->mac.num_rar_entries;···1415948 hw->addr_ctrl.mta_in_use = 0;14169491417950 /* Zero out the other receive addresses. */14181418- hw_dbg(hw, "Clearing RAR[1-15]\n");951951+ hw_dbg(hw, "Clearing RAR[%d-%d]\n", hw->addr_ctrl.rar_used_count,952952+ rar_entries - 1);1419953 for (i = hw->addr_ctrl.rar_used_count; i < rar_entries; i++) {1420954 IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);1421955 IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);···1436968 /* Enable mta */1437969 if (hw->addr_ctrl.mta_in_use > 0)1438970 IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,14391439- IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);971971+ IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);144097214411441- hw_dbg(hw, "ixgbe_update_mc_addr_list Complete\n");973973+ hw_dbg(hw, "ixgbe_update_mc_addr_list_generic Complete\n");1442974 return 0;1443975}14449761445977/**14461446- * ixgbe_clear_vfta - Clear VLAN filter table978978+ * ixgbe_enable_mc_generic - Enable multicast address in RAR1447979 * @hw: pointer to hardware structure1448980 *14491449- * Clears the VLAN filer table, and the VMDq index associated with the filter981981+ * Enables multicast address in RAR and the use of the multicast hash table.1450982 **/14511451-static s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)983983+s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw)1452984{14531453- u32 offset;14541454- u32 vlanbyte;985985+ u32 i;986986+ u32 rar_entries = hw->mac.num_rar_entries;987987+ struct ixgbe_addr_filter_info *a = &hw->addr_ctrl;145598814561456- for (offset = 0; offset < hw->mac.vft_size; offset++)14571457- IXGBE_WRITE_REG(hw, IXGBE_VFTA(offset), 0);989989+ if (a->mc_addr_in_rar_count > 0)990990+ for (i = (rar_entries - a->mc_addr_in_rar_count);991991+ i < rar_entries; i++)992992+ ixgbe_enable_rar(hw, i);145899314591459- for (vlanbyte = 0; vlanbyte < 4; vlanbyte++)14601460- for (offset = 0; offset < hw->mac.vft_size; offset++)14611461- IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(vlanbyte, offset),14621462- 0);14631463-14641464- return 0;14651465-}14661466-14671467-/**14681468- * ixgbe_set_vfta - Set VLAN filter table14691469- * @hw: pointer to hardware structure14701470- * @vlan: VLAN id to write to VLAN filter14711471- * @vind: VMDq output index that maps queue to VLAN id in VFTA14721472- * @vlan_on: boolean flag to turn on/off VLAN in VFTA14731473- *14741474- * Turn on/off specified VLAN in the VLAN filter table.14751475- **/14761476-s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind,14771477- bool vlan_on)14781478-{14791479- u32 VftaIndex;14801480- u32 BitOffset;14811481- u32 VftaReg;14821482- u32 VftaByte;14831483-14841484- /* Determine 32-bit word position in array */14851485- VftaIndex = (vlan >> 5) & 0x7F; /* upper seven bits */14861486-14871487- /* Determine the location of the (VMD) queue index */14881488- VftaByte = ((vlan >> 3) & 0x03); /* bits (4:3) indicating byte array */14891489- BitOffset = (vlan & 0x7) << 2; /* lower 3 bits indicate nibble */14901490-14911491- /* Set the nibble for VMD queue index */14921492- VftaReg = IXGBE_READ_REG(hw, IXGBE_VFTAVIND(VftaByte, VftaIndex));14931493- VftaReg &= (~(0x0F << BitOffset));14941494- VftaReg |= (vind << BitOffset);14951495- IXGBE_WRITE_REG(hw, IXGBE_VFTAVIND(VftaByte, VftaIndex), VftaReg);14961496-14971497- /* Determine the location of the bit for this VLAN id */14981498- BitOffset = vlan & 0x1F; /* lower five bits */14991499-15001500- VftaReg = IXGBE_READ_REG(hw, IXGBE_VFTA(VftaIndex));15011501- if (vlan_on)15021502- /* Turn on this VLAN id */15031503- VftaReg |= (1 << BitOffset);15041504- else15051505- /* Turn off this VLAN id */15061506- VftaReg &= ~(1 << BitOffset);15071507- IXGBE_WRITE_REG(hw, IXGBE_VFTA(VftaIndex), VftaReg);994994+ if (a->mta_in_use > 0)995995+ IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, IXGBE_MCSTCTRL_MFE |996996+ hw->mac.mc_filter_type);15089971509998 return 0;1510999}1511100015121001/**15131513- * ixgbe_setup_fc - Configure flow control settings10021002+ * ixgbe_disable_mc_generic - Disable multicast address in RAR15141003 * @hw: pointer to hardware structure15151515- * @packetbuf_num: packet buffer number (0-7)15161004 *15171517- * Configures the flow control settings based on SW configuration.15181518- * This function is used for 802.3x flow control configuration only.10051005+ * Disables multicast address in RAR and the use of the multicast hash table.15191006 **/15201520-s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)10071007+s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)15211008{15221522- u32 frctl_reg;15231523- u32 rmcs_reg;10091009+ u32 i;10101010+ u32 rar_entries = hw->mac.num_rar_entries;10111011+ struct ixgbe_addr_filter_info *a = &hw->addr_ctrl;1524101215251525- if (packetbuf_num < 0 || packetbuf_num > 7)15261526- hw_dbg(hw, "Invalid packet buffer number [%d], expected range "15271527- "is 0-7\n", packetbuf_num);10131013+ if (a->mc_addr_in_rar_count > 0)10141014+ for (i = (rar_entries - a->mc_addr_in_rar_count);10151015+ i < rar_entries; i++)10161016+ ixgbe_disable_rar(hw, i);1528101715291529- frctl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);15301530- frctl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);15311531-15321532- rmcs_reg = IXGBE_READ_REG(hw, IXGBE_RMCS);15331533- rmcs_reg &= ~(IXGBE_RMCS_TFCE_PRIORITY | IXGBE_RMCS_TFCE_802_3X);15341534-15351535- /*15361536- * 10 gig parts do not have a word in the EEPROM to determine the15371537- * default flow control setting, so we explicitly set it to full.15381538- */15391539- if (hw->fc.type == ixgbe_fc_default)15401540- hw->fc.type = ixgbe_fc_full;15411541-15421542- /*15431543- * We want to save off the original Flow Control configuration just in15441544- * case we get disconnected and then reconnected into a different hub15451545- * or switch with different Flow Control capabilities.15461546- */15471547- hw->fc.type = hw->fc.original_type;15481548-15491549- /*15501550- * The possible values of the "flow_control" parameter are:15511551- * 0: Flow control is completely disabled15521552- * 1: Rx flow control is enabled (we can receive pause frames but not15531553- * send pause frames).15541554- * 2: Tx flow control is enabled (we can send pause frames but we do not15551555- * support receiving pause frames)15561556- * 3: Both Rx and TX flow control (symmetric) are enabled.15571557- * other: Invalid.15581558- */15591559- switch (hw->fc.type) {15601560- case ixgbe_fc_none:15611561- break;15621562- case ixgbe_fc_rx_pause:15631563- /*15641564- * RX Flow control is enabled,15651565- * and TX Flow control is disabled.15661566- */15671567- frctl_reg |= IXGBE_FCTRL_RFCE;15681568- break;15691569- case ixgbe_fc_tx_pause:15701570- /*15711571- * TX Flow control is enabled, and RX Flow control is disabled,15721572- * by a software over-ride.15731573- */15741574- rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;15751575- break;15761576- case ixgbe_fc_full:15771577- /*15781578- * Flow control (both RX and TX) is enabled by a software15791579- * over-ride.15801580- */15811581- frctl_reg |= IXGBE_FCTRL_RFCE;15821582- rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;15831583- break;15841584- default:15851585- /* We should never get here. The value should be 0-3. */15861586- hw_dbg(hw, "Flow control param set incorrectly\n");15871587- break;15881588- }15891589-15901590- /* Enable 802.3x based flow control settings. */15911591- IXGBE_WRITE_REG(hw, IXGBE_FCTRL, frctl_reg);15921592- IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);15931593-15941594- /*15951595- * Check for invalid software configuration, zeros are completely15961596- * invalid for all parameters used past this point, and if we enable15971597- * flow control with zero water marks, we blast flow control packets.15981598- */15991599- if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {16001600- hw_dbg(hw, "Flow control structure initialized incorrectly\n");16011601- return IXGBE_ERR_INVALID_LINK_SETTINGS;16021602- }16031603-16041604- /*16051605- * We need to set up the Receive Threshold high and low water16061606- * marks as well as (optionally) enabling the transmission of16071607- * XON frames.16081608- */16091609- if (hw->fc.type & ixgbe_fc_tx_pause) {16101610- if (hw->fc.send_xon) {16111611- IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),16121612- (hw->fc.low_water | IXGBE_FCRTL_XONE));16131613- } else {16141614- IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num),16151615- hw->fc.low_water);16161616- }16171617- IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num),16181618- (hw->fc.high_water)|IXGBE_FCRTH_FCEN);16191619- }16201620-16211621- IXGBE_WRITE_REG(hw, IXGBE_FCTTV(0), hw->fc.pause_time);16221622- IXGBE_WRITE_REG(hw, IXGBE_FCRTV, (hw->fc.pause_time >> 1));10181018+ if (a->mta_in_use > 0)10191019+ IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);1623102016241021 return 0;16251022}···15001167 **/15011168s32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw)15021169{15031503- u32 ctrl;15041504- s32 i;11701170+ u32 i;11711171+ u32 reg_val;11721172+ u32 number_of_queues;15051173 s32 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;1506117415071507- ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);15081508- ctrl |= IXGBE_CTRL_GIO_DIS;15091509- IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);11751175+ /* Disable the receive unit by stopping each queue */11761176+ number_of_queues = hw->mac.max_rx_queues;11771177+ for (i = 0; i < number_of_queues; i++) {11781178+ reg_val = IXGBE_READ_REG(hw, IXGBE_RXDCTL(i));11791179+ if (reg_val & IXGBE_RXDCTL_ENABLE) {11801180+ reg_val &= ~IXGBE_RXDCTL_ENABLE;11811181+ IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(i), reg_val);11821182+ }11831183+ }11841184+11851185+ reg_val = IXGBE_READ_REG(hw, IXGBE_CTRL);11861186+ reg_val |= IXGBE_CTRL_GIO_DIS;11871187+ IXGBE_WRITE_REG(hw, IXGBE_CTRL, reg_val);1510118815111189 for (i = 0; i < IXGBE_PCI_MASTER_DISABLE_TIMEOUT; i++) {15121190 if (!(IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_GIO)) {···153211881533118915341190/**15351535- * ixgbe_acquire_swfw_sync - Aquire SWFW semaphore11911191+ * ixgbe_acquire_swfw_sync - Acquire SWFW semaphore15361192 * @hw: pointer to hardware structure15371537- * @mask: Mask to specify wich semaphore to acquire11931193+ * @mask: Mask to specify which semaphore to acquire15381194 *15391539- * Aquires the SWFW semaphore throught the GSSR register for the specified11951195+ * Acquires the SWFW semaphore thought the GSSR register for the specified15401196 * function (CSR, PHY0, PHY1, EEPROM, Flash)15411197 **/15421198s32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u16 mask)···15781234/**15791235 * ixgbe_release_swfw_sync - Release SWFW semaphore15801236 * @hw: pointer to hardware structure15811581- * @mask: Mask to specify wich semaphore to release12371237+ * @mask: Mask to specify which semaphore to release15821238 *15831583- * Releases the SWFW semaphore throught the GSSR register for the specified12391239+ * Releases the SWFW semaphore thought the GSSR register for the specified15841240 * function (CSR, PHY0, PHY1, EEPROM, Flash)15851241 **/15861242void ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u16 mask)···15951251 IXGBE_WRITE_REG(hw, IXGBE_GSSR, gssr);1596125215971253 ixgbe_release_eeprom_semaphore(hw);15981598-}15991599-16001600-/**16011601- * ixgbe_read_analog_reg8 - Reads 8 bit Atlas analog register16021602- * @hw: pointer to hardware structure16031603- * @reg: analog register to read16041604- * @val: read value16051605- *16061606- * Performs write operation to analog register specified.16071607- **/16081608-s32 ixgbe_read_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 *val)16091609-{16101610- u32 atlas_ctl;16111611-16121612- IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL,16131613- IXGBE_ATLASCTL_WRITE_CMD | (reg << 8));16141614- IXGBE_WRITE_FLUSH(hw);16151615- udelay(10);16161616- atlas_ctl = IXGBE_READ_REG(hw, IXGBE_ATLASCTL);16171617- *val = (u8)atlas_ctl;16181618-16191619- return 0;16201620-}16211621-16221622-/**16231623- * ixgbe_write_analog_reg8 - Writes 8 bit Atlas analog register16241624- * @hw: pointer to hardware structure16251625- * @reg: atlas register to write16261626- * @val: value to write16271627- *16281628- * Performs write operation to Atlas analog register specified.16291629- **/16301630-s32 ixgbe_write_analog_reg8(struct ixgbe_hw *hw, u32 reg, u8 val)16311631-{16321632- u32 atlas_ctl;16331633-16341634- atlas_ctl = (reg << 8) | val;16351635- IXGBE_WRITE_REG(hw, IXGBE_ATLASCTL, atlas_ctl);16361636- IXGBE_WRITE_FLUSH(hw);16371637- udelay(10);16381638-16391639- return 0;16401254}16411255
···371371 flags[i]);372372}373373374374-/* A flag indicating whether 'RX_PA_CFG_STRIP_VLAN_TAG' bit is set or not */375375-static int vlan_strip_flag;376376-377374/* Unregister the vlan */378375static void s2io_vlan_rx_kill_vid(struct net_device *dev, unsigned long vid)379376{···23002303 val64 = readq(&bar0->rx_pa_cfg);23012304 val64 &= ~RX_PA_CFG_STRIP_VLAN_TAG;23022305 writeq(val64, &bar0->rx_pa_cfg);23032303- vlan_strip_flag = 0;23062306+ nic->vlan_strip_flag = 0;23042307 }2305230823062309 /*···31333136 if (skb == NULL) {31343137 spin_unlock_irqrestore(&fifo_data->tx_lock, flags);31353138 DBG_PRINT(ERR_DBG, "%s: Null skb ",31363136- __FUNCTION__);31393139+ __func__);31373140 DBG_PRINT(ERR_DBG, "in Tx Free Intr\n");31383141 return;31393142 }···34933496 unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt;3494349734953498 DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n",34963496- __FUNCTION__, sp->dev->name);34993499+ __func__, sp->dev->name);3497350034983501 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */34993502 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));···35153518 }3516351935173520 if (check_pci_device_id(val16) == (u16)PCI_ANY_ID) {35183518- DBG_PRINT(ERR_DBG,"%s SW_Reset failed!\n", __FUNCTION__);35213521+ DBG_PRINT(ERR_DBG,"%s SW_Reset failed!\n", __func__);35193522 }3520352335213524 pci_write_config_word(sp->pdev, PCIX_COMMAND_REGISTER, pci_cmd);···37653768 val64 = (s2BIT(7) | s2BIT(15) | vBIT(msix_index, 26, 6));37663769 writeq(val64, &bar0->xmsi_access);37673770 if (wait_for_msix_trans(nic, msix_index)) {37683768- DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);37713771+ DBG_PRINT(ERR_DBG, "failed in %s\n", __func__);37693772 continue;37703773 }37713774 }···37863789 val64 = (s2BIT(15) | vBIT(msix_index, 26, 6));37873790 writeq(val64, &bar0->xmsi_access);37883791 if (wait_for_msix_trans(nic, msix_index)) {37893789- DBG_PRINT(ERR_DBG, "failed in %s\n", __FUNCTION__);37923792+ DBG_PRINT(ERR_DBG, "failed in %s\n", __func__);37903793 continue;37913794 }37923795 addr = readq(&bar0->xmsi_address);···38093812 GFP_KERNEL);38103813 if (!nic->entries) {38113814 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \38123812- __FUNCTION__);38153815+ __func__);38133816 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;38143817 return -ENOMEM;38153818 }···38233826 GFP_KERNEL);38243827 if (!nic->s2io_entries) {38253828 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n",38263826- __FUNCTION__);38293829+ __func__);38273830 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;38283831 kfree(nic->entries);38293832 nic->mac_control.stats_info->sw_stat.mem_freed···50075010 val64 = readq(&bar0->rx_pa_cfg);50085011 val64 &= ~RX_PA_CFG_STRIP_VLAN_TAG;50095012 writeq(val64, &bar0->rx_pa_cfg);50105010- vlan_strip_flag = 0;50135013+ sp->vlan_strip_flag = 0;50115014 }5012501550135016 val64 = readq(&bar0->mac_cfg);···50295032 val64 = readq(&bar0->rx_pa_cfg);50305033 val64 |= RX_PA_CFG_STRIP_VLAN_TAG;50315034 writeq(val64, &bar0->rx_pa_cfg);50325032- vlan_strip_flag = 1;50355035+ sp->vlan_strip_flag = 1;50335036 }5034503750355038 val64 = readq(&bar0->mac_cfg);···67436746 ret = s2io_card_up(sp);67446747 if (ret) {67456748 DBG_PRINT(ERR_DBG, "%s: Device bring up failed\n",67466746- __FUNCTION__);67496749+ __func__);67476750 return ret;67486751 }67496752 s2io_wake_all_tx_queue(sp);···75277530 default:75287531 DBG_PRINT(ERR_DBG,75297532 "%s: Samadhana!!\n",75307530- __FUNCTION__);75337533+ __func__);75317534 BUG();75327535 }75337536 }···77787781 return -ENOMEM;77797782 }77807783 if ((ret = pci_request_regions(pdev, s2io_driver_name))) {77817781- DBG_PRINT(ERR_DBG, "%s: Request Regions failed - %x \n", __FUNCTION__, ret);77847784+ DBG_PRINT(ERR_DBG, "%s: Request Regions failed - %x \n", __func__, ret);77827785 pci_disable_device(pdev);77837786 return -ENODEV;77847787 }···79957998 if (sp->device_type & XFRAME_II_DEVICE) {79967999 mode = s2io_verify_pci_mode(sp);79978000 if (mode < 0) {79987998- DBG_PRINT(ERR_DBG, "%s: ", __FUNCTION__);80018001+ DBG_PRINT(ERR_DBG, "%s: ", __func__);79998002 DBG_PRINT(ERR_DBG, " Unsupported PCI bus mode\n");80008003 ret = -EBADSLT;80018004 goto set_swap_failed;···82038206 /* Initialize device name */82048207 sprintf(sp->name, "%s Neterion %s", dev->name, sp->product_name);8205820882098209+ if (vlan_tag_strip)82108210+ sp->vlan_strip_flag = 1;82118211+ else82128212+ sp->vlan_strip_flag = 0;82138213+82068214 /*82078215 * Make Link state as off at this point, when the Link change82088216 * interrupt comes the state will be automatically changed to···8301829983028300 if (!(rxdp->Control_1 & RXD_FRAME_PROTO_TCP)) {83038301 DBG_PRINT(INIT_DBG,"%s: Non-TCP frames not supported for LRO\n",83048304- __FUNCTION__);83028302+ __func__);83058303 return -1;83068304 }83078305···83138311 * If vlan stripping is disabled and the frame is VLAN tagged,83148312 * shift the offset by the VLAN header size bytes.83158313 */83168316- if ((!vlan_strip_flag) &&83148314+ if ((!sp->vlan_strip_flag) &&83178315 (rxdp->Control_1 & RXD_FRAME_VLAN_TAG))83188316 ip_off += HEADER_VLAN_SIZE;83198317 } else {···83328330static int check_for_socket_match(struct lro *lro, struct iphdr *ip,83338331 struct tcphdr *tcp)83348332{83358335- DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);83338333+ DBG_PRINT(INFO_DBG,"%s: Been here...\n", __func__);83368334 if ((lro->iph->saddr != ip->saddr) || (lro->iph->daddr != ip->daddr) ||83378335 (lro->tcph->source != tcp->source) || (lro->tcph->dest != tcp->dest))83388336 return -1;···83478345static void initiate_new_session(struct lro *lro, u8 *l2h,83488346 struct iphdr *ip, struct tcphdr *tcp, u32 tcp_pyld_len, u16 vlan_tag)83498347{83508350- DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);83488348+ DBG_PRINT(INFO_DBG,"%s: Been here...\n", __func__);83518349 lro->l2h = l2h;83528350 lro->iph = ip;83538351 lro->tcph = tcp;···83778375 struct tcphdr *tcp = lro->tcph;83788376 __sum16 nchk;83798377 struct stat_block *statinfo = sp->mac_control.stats_info;83808380- DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);83788378+ DBG_PRINT(INFO_DBG,"%s: Been here...\n", __func__);8381837983828380 /* Update L3 header */83838381 ip->tot_len = htons(lro->total_len);···84058403static void aggregate_new_rx(struct lro *lro, struct iphdr *ip,84068404 struct tcphdr *tcp, u32 l4_pyld)84078405{84088408- DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);84068406+ DBG_PRINT(INFO_DBG,"%s: Been here...\n", __func__);84098407 lro->total_len += l4_pyld;84108408 lro->frags_len += l4_pyld;84118409 lro->tcp_next_seq += l4_pyld;···84298427{84308428 u8 *ptr;8431842984328432- DBG_PRINT(INFO_DBG,"%s: Been here...\n", __FUNCTION__);84308430+ DBG_PRINT(INFO_DBG,"%s: Been here...\n", __func__);8433843184348432 if (!tcp_pyld_len) {84358433 /* Runt frame or a pure ack */···8511850985128510 if ((*lro)->tcp_next_seq != ntohl(tcph->seq)) {85138511 DBG_PRINT(INFO_DBG, "%s:Out of order. expected "85148514- "0x%x, actual 0x%x\n", __FUNCTION__,85128512+ "0x%x, actual 0x%x\n", __func__,85158513 (*lro)->tcp_next_seq,85168514 ntohl(tcph->seq));85178515···8551854985528550 if (ret == 0) { /* sessions exceeded */85538551 DBG_PRINT(INFO_DBG,"%s:All LRO sessions already in use\n",85548554- __FUNCTION__);85528552+ __func__);85558553 *lro = NULL;85568554 return ret;85578555 }···85738571 break;85748572 default:85758573 DBG_PRINT(ERR_DBG,"%s:Dont know, can't say!!\n",85768576- __FUNCTION__);85748574+ __func__);85778575 break;85788576 }85798577···8594859285958593 skb->protocol = eth_type_trans(skb, dev);85968594 if (sp->vlgrp && vlan_tag85978597- && (vlan_strip_flag)) {85958595+ && (sp->vlan_strip_flag)) {85988596 /* Queueing the vlan frame to the upper layer */85998597 if (sp->config.napi)86008598 vlan_hwaccel_receive_skb(skb, sp->vlgrp, vlan_tag);
+1
drivers/net/s2io.h
···962962 int task_flag;963963 unsigned long long start_time;964964 struct vlan_group *vlgrp;965965+ int vlan_strip_flag;965966#define MSIX_FLG 0xA5966967 int num_entries;967968 struct msix_entry *entries;
+8-10
drivers/net/sfc/efx.c
···445445 struct efx_channel *channel;446446 struct efx_tx_queue *tx_queue;447447 struct efx_rx_queue *rx_queue;448448+ int rc;448449449450 EFX_ASSERT_RESET_SERIALISED(efx);450451 BUG_ON(efx->port_enabled);452452+453453+ rc = falcon_flush_queues(efx);454454+ if (rc)455455+ EFX_ERR(efx, "failed to flush queues\n");456456+ else457457+ EFX_LOG(efx, "successfully flushed all queues\n");451458452459 efx_for_each_channel(channel, efx) {453460 EFX_LOG(channel->efx, "shut down chan %d\n", channel->channel);···463456 efx_fini_rx_queue(rx_queue);464457 efx_for_each_channel_tx_queue(tx_queue, channel)465458 efx_fini_tx_queue(tx_queue);466466- }467467-468468- /* Do the event queues last so that we can handle flush events469469- * for all DMA queues. */470470- efx_for_each_channel(channel, efx) {471471- EFX_LOG(channel->efx, "shut down evq %d\n", channel->channel);472472-473459 efx_fini_eventq(channel);474460 }475461}···780780 return 0;781781782782 fail4:783783- release_mem_region(efx->membase_phys, efx->type->mem_map_size);783783+ pci_release_region(efx->pci_dev, efx->type->mem_bar);784784 fail3:785785 efx->membase_phys = 0;786786 fail2:···1092109210931093 /* Isolate the MAC from the TX and RX engines, so that queue10941094 * flushes will complete in a timely fashion. */10951095- falcon_deconfigure_mac_wrapper(efx);10961095 falcon_drain_tx_fifo(efx);1097109610981097 /* Stop the kernel transmit interface late, so the watchdog···17491750 .check_hw = efx_port_dummy_op_int,17501751 .fini = efx_port_dummy_op_void,17511752 .clear_interrupt = efx_port_dummy_op_void,17521752- .reset_xaui = efx_port_dummy_op_void,17531753};1754175417551755static struct efx_board efx_dummy_board_info = {
+138-122
drivers/net/sfc/falcon.c
···108108/* Max number of internal errors. After this resets will not be performed */109109#define FALCON_MAX_INT_ERRORS 4110110111111-/* Maximum period that we wait for flush events. If the flush event112112- * doesn't arrive in this period of time then we check if the queue113113- * was disabled anyway. */114114-#define FALCON_FLUSH_TIMEOUT 10 /* 10ms */111111+/* We poll for events every FLUSH_INTERVAL ms, and check FLUSH_POLL_COUNT times112112+ */113113+#define FALCON_FLUSH_INTERVAL 10114114+#define FALCON_FLUSH_POLL_COUNT 100115115116116/**************************************************************************117117 *···452452 efx_oword_t tx_desc_ptr;453453 struct efx_nic *efx = tx_queue->efx;454454455455+ tx_queue->flushed = false;456456+455457 /* Pin TX descriptor ring */456458 falcon_init_special_buffer(efx, &tx_queue->txd);457459···494492 }495493}496494497497-static int falcon_flush_tx_queue(struct efx_tx_queue *tx_queue)495495+static void falcon_flush_tx_queue(struct efx_tx_queue *tx_queue)498496{499497 struct efx_nic *efx = tx_queue->efx;500500- struct efx_channel *channel = &efx->channel[0];501498 efx_oword_t tx_flush_descq;502502- unsigned int read_ptr, i;503499504500 /* Post a flush command */505501 EFX_POPULATE_OWORD_2(tx_flush_descq,506502 TX_FLUSH_DESCQ_CMD, 1,507503 TX_FLUSH_DESCQ, tx_queue->queue);508504 falcon_write(efx, &tx_flush_descq, TX_FLUSH_DESCQ_REG_KER);509509- msleep(FALCON_FLUSH_TIMEOUT);510510-511511- if (EFX_WORKAROUND_7803(efx))512512- return 0;513513-514514- /* Look for a flush completed event */515515- read_ptr = channel->eventq_read_ptr;516516- for (i = 0; i < FALCON_EVQ_SIZE; ++i) {517517- efx_qword_t *event = falcon_event(channel, read_ptr);518518- int ev_code, ev_sub_code, ev_queue;519519- if (!falcon_event_present(event))520520- break;521521-522522- ev_code = EFX_QWORD_FIELD(*event, EV_CODE);523523- ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);524524- ev_queue = EFX_QWORD_FIELD(*event, DRIVER_EV_TX_DESCQ_ID);525525- if ((ev_sub_code == TX_DESCQ_FLS_DONE_EV_DECODE) &&526526- (ev_queue == tx_queue->queue)) {527527- EFX_LOG(efx, "tx queue %d flush command succesful\n",528528- tx_queue->queue);529529- return 0;530530- }531531-532532- read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;533533- }534534-535535- if (EFX_WORKAROUND_11557(efx)) {536536- efx_oword_t reg;537537- bool enabled;538538-539539- falcon_read_table(efx, ®, efx->type->txd_ptr_tbl_base,540540- tx_queue->queue);541541- enabled = EFX_OWORD_FIELD(reg, TX_DESCQ_EN);542542- if (!enabled) {543543- EFX_LOG(efx, "tx queue %d disabled without a "544544- "flush event seen\n", tx_queue->queue);545545- return 0;546546- }547547- }548548-549549- EFX_ERR(efx, "tx queue %d flush command timed out\n", tx_queue->queue);550550- return -ETIMEDOUT;551505}552506553507void falcon_fini_tx(struct efx_tx_queue *tx_queue)···511553 struct efx_nic *efx = tx_queue->efx;512554 efx_oword_t tx_desc_ptr;513555514514- /* Stop the hardware using the queue */515515- if (falcon_flush_tx_queue(tx_queue))516516- EFX_ERR(efx, "failed to flush tx queue %d\n", tx_queue->queue);556556+ /* The queue should have been flushed */557557+ WARN_ON(!tx_queue->flushed);517558518559 /* Remove TX descriptor ring from card */519560 EFX_ZERO_OWORD(tx_desc_ptr);···600643 rx_queue->queue, rx_queue->rxd.index,601644 rx_queue->rxd.index + rx_queue->rxd.entries - 1);602645646646+ rx_queue->flushed = false;647647+603648 /* Pin RX descriptor ring */604649 falcon_init_special_buffer(efx, &rx_queue->rxd);605650···622663 rx_queue->queue);623664}624665625625-static int falcon_flush_rx_queue(struct efx_rx_queue *rx_queue)666666+static void falcon_flush_rx_queue(struct efx_rx_queue *rx_queue)626667{627668 struct efx_nic *efx = rx_queue->efx;628628- struct efx_channel *channel = &efx->channel[0];629629- unsigned int read_ptr, i;630669 efx_oword_t rx_flush_descq;631670632671 /* Post a flush command */···632675 RX_FLUSH_DESCQ_CMD, 1,633676 RX_FLUSH_DESCQ, rx_queue->queue);634677 falcon_write(efx, &rx_flush_descq, RX_FLUSH_DESCQ_REG_KER);635635- msleep(FALCON_FLUSH_TIMEOUT);636636-637637- if (EFX_WORKAROUND_7803(efx))638638- return 0;639639-640640- /* Look for a flush completed event */641641- read_ptr = channel->eventq_read_ptr;642642- for (i = 0; i < FALCON_EVQ_SIZE; ++i) {643643- efx_qword_t *event = falcon_event(channel, read_ptr);644644- int ev_code, ev_sub_code, ev_queue;645645- bool ev_failed;646646- if (!falcon_event_present(event))647647- break;648648-649649- ev_code = EFX_QWORD_FIELD(*event, EV_CODE);650650- ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);651651- ev_queue = EFX_QWORD_FIELD(*event, DRIVER_EV_RX_DESCQ_ID);652652- ev_failed = EFX_QWORD_FIELD(*event, DRIVER_EV_RX_FLUSH_FAIL);653653-654654- if ((ev_sub_code == RX_DESCQ_FLS_DONE_EV_DECODE) &&655655- (ev_queue == rx_queue->queue)) {656656- if (ev_failed) {657657- EFX_INFO(efx, "rx queue %d flush command "658658- "failed\n", rx_queue->queue);659659- return -EAGAIN;660660- } else {661661- EFX_LOG(efx, "rx queue %d flush command "662662- "succesful\n", rx_queue->queue);663663- return 0;664664- }665665- }666666-667667- read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;668668- }669669-670670- if (EFX_WORKAROUND_11557(efx)) {671671- efx_oword_t reg;672672- bool enabled;673673-674674- falcon_read_table(efx, ®, efx->type->rxd_ptr_tbl_base,675675- rx_queue->queue);676676- enabled = EFX_OWORD_FIELD(reg, RX_DESCQ_EN);677677- if (!enabled) {678678- EFX_LOG(efx, "rx queue %d disabled without a "679679- "flush event seen\n", rx_queue->queue);680680- return 0;681681- }682682- }683683-684684- EFX_ERR(efx, "rx queue %d flush command timed out\n", rx_queue->queue);685685- return -ETIMEDOUT;686678}687679688680void falcon_fini_rx(struct efx_rx_queue *rx_queue)689681{690682 efx_oword_t rx_desc_ptr;691683 struct efx_nic *efx = rx_queue->efx;692692- int i, rc;693684694694- /* Try and flush the rx queue. This may need to be repeated */695695- for (i = 0; i < 5; i++) {696696- rc = falcon_flush_rx_queue(rx_queue);697697- if (rc == -EAGAIN)698698- continue;699699- break;700700- }701701- if (rc) {702702- EFX_ERR(efx, "failed to flush rx queue %d\n", rx_queue->queue);703703- efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);704704- }685685+ /* The queue should already have been flushed */686686+ WARN_ON(!rx_queue->flushed);705687706688 /* Remove RX descriptor ring from card */707689 EFX_ZERO_OWORD(rx_desc_ptr);···9031007 is_phy_event = true;90410089051009 if ((falcon_rev(efx) >= FALCON_REV_B0) &&906906- EFX_OWORD_FIELD(*event, XG_MNT_INTR_B0))10101010+ EFX_QWORD_FIELD(*event, XG_MNT_INTR_B0))9071011 is_phy_event = true;90810129091013 if (is_phy_event) {···11511255 falcon_generate_event(channel, &test_event);11521256}1153125712581258+/**************************************************************************12591259+ *12601260+ * Flush handling12611261+ *12621262+ **************************************************************************/12631263+12641264+12651265+static void falcon_poll_flush_events(struct efx_nic *efx)12661266+{12671267+ struct efx_channel *channel = &efx->channel[0];12681268+ struct efx_tx_queue *tx_queue;12691269+ struct efx_rx_queue *rx_queue;12701270+ unsigned int read_ptr, i;12711271+12721272+ read_ptr = channel->eventq_read_ptr;12731273+ for (i = 0; i < FALCON_EVQ_SIZE; ++i) {12741274+ efx_qword_t *event = falcon_event(channel, read_ptr);12751275+ int ev_code, ev_sub_code, ev_queue;12761276+ bool ev_failed;12771277+ if (!falcon_event_present(event))12781278+ break;12791279+12801280+ ev_code = EFX_QWORD_FIELD(*event, EV_CODE);12811281+ if (ev_code != DRIVER_EV_DECODE)12821282+ continue;12831283+12841284+ ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);12851285+ switch (ev_sub_code) {12861286+ case TX_DESCQ_FLS_DONE_EV_DECODE:12871287+ ev_queue = EFX_QWORD_FIELD(*event,12881288+ DRIVER_EV_TX_DESCQ_ID);12891289+ if (ev_queue < EFX_TX_QUEUE_COUNT) {12901290+ tx_queue = efx->tx_queue + ev_queue;12911291+ tx_queue->flushed = true;12921292+ }12931293+ break;12941294+ case RX_DESCQ_FLS_DONE_EV_DECODE:12951295+ ev_queue = EFX_QWORD_FIELD(*event,12961296+ DRIVER_EV_RX_DESCQ_ID);12971297+ ev_failed = EFX_QWORD_FIELD(*event,12981298+ DRIVER_EV_RX_FLUSH_FAIL);12991299+ if (ev_queue < efx->n_rx_queues) {13001300+ rx_queue = efx->rx_queue + ev_queue;13011301+13021302+ /* retry the rx flush */13031303+ if (ev_failed)13041304+ falcon_flush_rx_queue(rx_queue);13051305+ else13061306+ rx_queue->flushed = true;13071307+ }13081308+ break;13091309+ }13101310+13111311+ read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;13121312+ }13131313+}13141314+13151315+/* Handle tx and rx flushes at the same time, since they run in13161316+ * parallel in the hardware and there's no reason for us to13171317+ * serialise them */13181318+int falcon_flush_queues(struct efx_nic *efx)13191319+{13201320+ struct efx_rx_queue *rx_queue;13211321+ struct efx_tx_queue *tx_queue;13221322+ int i;13231323+ bool outstanding;13241324+13251325+ /* Issue flush requests */13261326+ efx_for_each_tx_queue(tx_queue, efx) {13271327+ tx_queue->flushed = false;13281328+ falcon_flush_tx_queue(tx_queue);13291329+ }13301330+ efx_for_each_rx_queue(rx_queue, efx) {13311331+ rx_queue->flushed = false;13321332+ falcon_flush_rx_queue(rx_queue);13331333+ }13341334+13351335+ /* Poll the evq looking for flush completions. Since we're not pushing13361336+ * any more rx or tx descriptors at this point, we're in no danger of13371337+ * overflowing the evq whilst we wait */13381338+ for (i = 0; i < FALCON_FLUSH_POLL_COUNT; ++i) {13391339+ msleep(FALCON_FLUSH_INTERVAL);13401340+ falcon_poll_flush_events(efx);13411341+13421342+ /* Check if every queue has been succesfully flushed */13431343+ outstanding = false;13441344+ efx_for_each_tx_queue(tx_queue, efx)13451345+ outstanding |= !tx_queue->flushed;13461346+ efx_for_each_rx_queue(rx_queue, efx)13471347+ outstanding |= !rx_queue->flushed;13481348+ if (!outstanding)13491349+ return 0;13501350+ }13511351+13521352+ /* Mark the queues as all flushed. We're going to return failure13531353+ * leading to a reset, or fake up success anyway. "flushed" now13541354+ * indicates that we tried to flush. */13551355+ efx_for_each_tx_queue(tx_queue, efx) {13561356+ if (!tx_queue->flushed)13571357+ EFX_ERR(efx, "tx queue %d flush command timed out\n",13581358+ tx_queue->queue);13591359+ tx_queue->flushed = true;13601360+ }13611361+ efx_for_each_rx_queue(rx_queue, efx) {13621362+ if (!rx_queue->flushed)13631363+ EFX_ERR(efx, "rx queue %d flush command timed out\n",13641364+ rx_queue->queue);13651365+ rx_queue->flushed = true;13661366+ }13671367+13681368+ if (EFX_WORKAROUND_7803(efx))13691369+ return 0;13701370+13711371+ return -ETIMEDOUT;13721372+}1154137311551374/**************************************************************************11561375 *···13741363 EFX_OWORD_FMT "\n", EFX_OWORD_VAL(reg));13751364 }1376136513771377- /* Disable DMA bus mastering on both devices */13661366+ /* Disable both devices */13781367 pci_disable_device(efx->pci_dev);13791368 if (FALCON_IS_DUAL_FUNC(efx))13801369 pci_disable_device(nic_data->pci_dev2);13701370+ falcon_disable_interrupts(efx);1381137113821372 if (++n_int_errors < FALCON_MAX_INT_ERRORS) {13831373 EFX_ERR(efx, "SYSTEM ERROR - reset scheduled\n");···16051593 **************************************************************************16061594 */1607159516081608-#define FALCON_SPI_MAX_LEN sizeof(efx_oword_t)15961596+#define FALCON_SPI_MAX_LEN ((unsigned) sizeof(efx_oword_t))1609159716101598/* Wait for SPI command completion */16111599static int falcon_spi_wait(struct efx_nic *efx)···1954194219551943 /* Wait for transfer to complete */19561944 for (i = 0; i < 400; i++) {19571957- if (*(volatile u32 *)dma_done == FALCON_STATS_DONE)19451945+ if (*(volatile u32 *)dma_done == FALCON_STATS_DONE) {19461946+ rmb(); /* Ensure the stats are valid. */19581947 return 0;19481948+ }19591949 udelay(10);19601950 }19611951···2772275827732759 /* Allocate storage for hardware specific data */27742760 nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL);27612761+ if (!nic_data)27622762+ return -ENOMEM;27752763 efx->nic_data = nic_data;2776276427772765 /* Determine number of ports etc. */
+1
drivers/net/sfc/falcon.h
···8686extern int falcon_probe_nic(struct efx_nic *efx);8787extern int falcon_probe_resources(struct efx_nic *efx);8888extern int falcon_init_nic(struct efx_nic *efx);8989+extern int falcon_flush_queues(struct efx_nic *efx);8990extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);9091extern void falcon_remove_resources(struct efx_nic *efx);9192extern void falcon_remove_nic(struct efx_nic *efx);
-1
drivers/net/sfc/falcon_hwdefs.h
···117117#define SF_PRST_WIDTH 1118118#define EE_PRST_LBN 8119119#define EE_PRST_WIDTH 1120120-/* See pic_mode_t for decoding of this field */121120/* These bit definitions are extrapolated from the list of numerical122121 * values for STRAP_PINS.123122 */
···160160 * @channel: The associated channel161161 * @buffer: The software buffer ring162162 * @txd: The hardware descriptor ring163163+ * @flushed: Used when handling queue flushing163164 * @read_count: Current read pointer.164165 * This is the number of buffers that have been removed from both rings.165166 * @stopped: Stopped count.···193192 struct efx_nic *nic;194193 struct efx_tx_buffer *buffer;195194 struct efx_special_buffer txd;195195+ bool flushed;196196197197 /* Members used mainly on the completion path */198198 unsigned int read_count ____cacheline_aligned_in_smp;···262260 * the remaining space in the allocation.263261 * @buf_dma_addr: Page's DMA address.264262 * @buf_data: Page's host address.263263+ * @flushed: Use when handling queue flushing265264 */266265struct efx_rx_queue {267266 struct efx_nic *efx;···288285 struct page *buf_page;289286 dma_addr_t buf_dma_addr;290287 char *buf_data;288288+ bool flushed;291289};292290293291/**···474470 * This is the equivalent of NET_IP_ALIGN [which controls the alignment475471 * of the skb->head for hardware DMA].476472 */477477-#if defined(__i386__) || defined(__x86_64__)473473+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS478474#define EFX_PAGE_IP_ALIGN 0479475#else480476#define EFX_PAGE_IP_ALIGN NET_IP_ALIGN···507503 * @clear_interrupt: Clear down interrupt508504 * @blink: Blink LEDs509505 * @check_hw: Check hardware510510- * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset)511506 * @mmds: MMD presence mask512507 * @loopbacks: Supported loopback modes mask513508 */···516513 void (*reconfigure) (struct efx_nic *efx);517514 void (*clear_interrupt) (struct efx_nic *efx);518515 int (*check_hw) (struct efx_nic *efx);519519- void (*reset_xaui) (struct efx_nic *efx);520516 int (*test) (struct efx_nic *efx);521517 int mmds;522518 unsigned loopbacks;
-12
drivers/net/sfc/sfe4001.c
···129129 unsigned int i, j;130130 int rc;131131 u8 out;132132- efx_oword_t reg;133133-134134- /* Ensure that XGXS and XAUI SerDes are held in reset */135135- EFX_POPULATE_OWORD_7(reg, XX_PWRDNA_EN, 1,136136- XX_PWRDNB_EN, 1,137137- XX_RSTPLLAB_EN, 1,138138- XX_RESETA_EN, 1,139139- XX_RESETB_EN, 1,140140- XX_RSTXGXSRX_EN, 1,141141- XX_RSTXGXSTX_EN, 1);142142- falcon_write(efx, ®, XX_PWR_RST_REG);143143- udelay(10);144132145133 /* Clear any previous over-temperature alert */146134 rc = i2c_smbus_read_byte_data(hwmon_client, RSL);
+11-58
drivers/net/sfc/tenxpress.c
···146146 return 0;147147}148148149149-static void tenxpress_reset_xaui(struct efx_nic *efx);150150-151149static int tenxpress_init(struct efx_nic *efx)152150{153151 int rc, reg;···214216{215217 int rc, reg;216218217217- EFX_TRACE(efx, "%s\n", __func__);219219+ /* The XGMAC clock is driven from the SFC7101/SFT9001 312MHz clock, so220220+ * a special software reset can glitch the XGMAC sufficiently for stats221221+ * requests to fail. Since we don't ofen special_reset, just lock. */222222+ spin_lock(&efx->stats_lock);218223219224 /* Initiate reset */220225 reg = mdio_clause45_read(efx, efx->mii.phy_id,···226225 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,227226 PMA_PMD_EXT_CTRL_REG, reg);228227229229- msleep(200);228228+ mdelay(200);230229231230 /* Wait for the blocks to come out of reset */232231 rc = mdio_clause45_wait_reset_mmds(efx,233232 TENXPRESS_REQUIRED_DEVS);234233 if (rc < 0)235235- return rc;234234+ goto unlock;236235237236 /* Try and reconfigure the device */238237 rc = tenxpress_init(efx);239238 if (rc < 0)240240- return rc;239239+ goto unlock;241240242242- return 0;241241+unlock:242242+ spin_unlock(&efx->stats_lock);243243+ return rc;243244}244245245246static void tenxpress_set_bad_lp(struct efx_nic *efx, bool bad_lp)···377374 struct tenxpress_phy_data *phy_data = efx->phy_data;378375 bool link_ok;379376380380- link_ok = (phy_data->phy_mode == PHY_MODE_NORMAL &&381381- tenxpress_link_ok(efx, true));377377+ link_ok = tenxpress_link_ok(efx, true);382378383379 if (link_ok != efx->link_up)384380 falcon_xmac_sim_phy_event(efx);···430428 PMA_PMD_LED_OVERR_REG, reg);431429}432430433433-static void tenxpress_reset_xaui(struct efx_nic *efx)434434-{435435- int phy = efx->mii.phy_id;436436- int clk_ctrl, test_select, soft_rst2;437437-438438- /* Real work is done on clock_ctrl other resets are thought to be439439- * optional but make the reset more reliable440440- */441441-442442- /* Read */443443- clk_ctrl = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,444444- PCS_CLOCK_CTRL_REG);445445- test_select = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,446446- PCS_TEST_SELECT_REG);447447- soft_rst2 = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,448448- PCS_SOFT_RST2_REG);449449-450450- /* Put in reset */451451- test_select &= ~(1 << CLK312_EN_LBN);452452- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,453453- PCS_TEST_SELECT_REG, test_select);454454-455455- soft_rst2 &= ~((1 << XGXS_RST_N_LBN) | (1 << SERDES_RST_N_LBN));456456- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,457457- PCS_SOFT_RST2_REG, soft_rst2);458458-459459- clk_ctrl &= ~(1 << PLL312_RST_N_LBN);460460- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,461461- PCS_CLOCK_CTRL_REG, clk_ctrl);462462- udelay(10);463463-464464- /* Remove reset */465465- clk_ctrl |= (1 << PLL312_RST_N_LBN);466466- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,467467- PCS_CLOCK_CTRL_REG, clk_ctrl);468468- udelay(10);469469-470470- soft_rst2 |= ((1 << XGXS_RST_N_LBN) | (1 << SERDES_RST_N_LBN));471471- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,472472- PCS_SOFT_RST2_REG, soft_rst2);473473- udelay(10);474474-475475- test_select |= (1 << CLK312_EN_LBN);476476- mdio_clause45_write(efx, phy, MDIO_MMD_PCS,477477- PCS_TEST_SELECT_REG, test_select);478478- udelay(10);479479-}480480-481431static int tenxpress_phy_test(struct efx_nic *efx)482432{483433 /* BIST is automatically run after a special software reset */···442488 .check_hw = tenxpress_phy_check_hw,443489 .fini = tenxpress_phy_fini,444490 .clear_interrupt = tenxpress_phy_clear_interrupt,445445- .reset_xaui = tenxpress_reset_xaui,446491 .test = tenxpress_phy_test,447492 .mmds = TENXPRESS_REQUIRED_DEVS,448493 .loopbacks = TENXPRESS_LOOPBACKS,
+1-1
drivers/net/sfc/tx.c
···516516/* Number of bytes inserted at the start of a TSO header buffer,517517 * similar to NET_IP_ALIGN.518518 */519519-#if defined(__i386__) || defined(__x86_64__)519519+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS520520#define TSOH_OFFSET 0521521#else522522#define TSOH_OFFSET NET_IP_ALIGN
-2
drivers/net/sfc/workarounds.h
···2424#define EFX_WORKAROUND_7575 EFX_WORKAROUND_ALWAYS2525/* TX pkt parser problem with <= 16 byte TXes */2626#define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS2727-/* XGXS and XAUI reset sequencing in SW */2828-#define EFX_WORKAROUND_9388 EFX_WORKAROUND_ALWAYS2927/* Low rate CRC errors require XAUI reset */3028#define EFX_WORKAROUND_10750 EFX_WORKAROUND_ALWAYS3129/* TX_EV_PKT_ERR can be caused by a dangling TX descriptor
···263263 return;264264 udelay(10);265265 }266266- printk(KERN_ERR "%s function time out \n", __FUNCTION__);266266+ printk(KERN_ERR "%s function time out \n", __func__);267267}268268269269static int mii_speed(struct mii_if_info *mii)···10591059 return;10601060 udelay(10);10611061 }10621062- printk(KERN_ERR "%s function time out \n", __FUNCTION__);10621062+ printk(KERN_ERR "%s function time out \n", __func__);10631063}1064106410651065static void tsi108_reset_ether(struct tsi108_prv_data * data)···12441244 udelay(10);12451245 }12461246 if (i == 0)12471247- printk(KERN_ERR "%s function time out \n", __FUNCTION__);12471247+ printk(KERN_ERR "%s function time out \n", __func__);1248124812491249 if (data->phy_type == TSI108_PHY_BCM54XX) {12501250 tsi108_write_mii(data, 0x09, 0x0300);
···400400 enet_addr_cont = kmalloc(sizeof(struct enet_addr_container), GFP_KERNEL);401401 if (!enet_addr_cont) {402402 ugeth_err("%s: No memory for enet_addr_container object.",403403- __FUNCTION__);403403+ __func__);404404 return NULL;405405 }406406···427427 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;428428429429 if (!(paddr_num < NUM_OF_PADDRS)) {430430- ugeth_warn("%s: Illegal paddr_num.", __FUNCTION__);430430+ ugeth_warn("%s: Illegal paddr_num.", __func__);431431 return -EINVAL;432432 }433433···447447 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;448448449449 if (!(paddr_num < NUM_OF_PADDRS)) {450450- ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__);450450+ ugeth_warn("%s: Illagel paddr_num.", __func__);451451 return -EINVAL;452452 }453453···14411441 u32 upsmr, maccfg2, tbiBaseAddress;14421442 u16 value;1443144314441444- ugeth_vdbg("%s: IN", __FUNCTION__);14441444+ ugeth_vdbg("%s: IN", __func__);1445144514461446 ug_info = ugeth->ug_info;14471447 ug_regs = ugeth->ug_regs;···15041504 if (ret_val != 0) {15051505 if (netif_msg_probe(ugeth))15061506 ugeth_err("%s: Preamble length must be between 3 and 7 inclusive.",15071507- __FUNCTION__);15071507+ __func__);15081508 return ret_val;15091509 }15101510···17441744 /* check if the UCC number is in range. */17451745 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) {17461746 if (netif_msg_probe(ugeth))17471747- ugeth_err("%s: ucc_num out of range.", __FUNCTION__);17471747+ ugeth_err("%s: ucc_num out of range.", __func__);17481748 return -EINVAL;17491749 }17501750···17731773 /* check if the UCC number is in range. */17741774 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) {17751775 if (netif_msg_probe(ugeth))17761776- ugeth_err("%s: ucc_num out of range.", __FUNCTION__);17761776+ ugeth_err("%s: ucc_num out of range.", __func__);17771777 return -EINVAL;17781778 }17791779···20622062 ugeth_warn20632063 ("%s: multicast address added to paddr will have no "20642064 "effect - is this what you wanted?",20652065- __FUNCTION__);20652065+ __func__);2066206620672067 ugeth->indAddrRegUsed[paddr_num] = 1; /* mark this paddr as used */20682068 /* store address in our database */···22782278 struct phy_device *phydev = ugeth->phydev;22792279 u32 tempval;2280228022812281- ugeth_vdbg("%s: IN", __FUNCTION__);22812281+ ugeth_vdbg("%s: IN", __func__);2282228222832283 /* Disable the controller */22842284 ugeth_disable(ugeth, COMM_DIR_RX_AND_TX);···23152315 (uf_info->bd_mem_part == MEM_PART_MURAM))) {23162316 if (netif_msg_probe(ugeth))23172317 ugeth_err("%s: Bad memory partition value.",23182318- __FUNCTION__);23182318+ __func__);23192319 return -EINVAL;23202320 }23212321···23272327 if (netif_msg_probe(ugeth))23282328 ugeth_err23292329 ("%s: Rx BD ring length must be multiple of 4, no smaller than 8.",23302330- __FUNCTION__);23302330+ __func__);23312331 return -EINVAL;23322332 }23332333 }···23382338 if (netif_msg_probe(ugeth))23392339 ugeth_err23402340 ("%s: Tx BD ring length must be no smaller than 2.",23412341- __FUNCTION__);23412341+ __func__);23422342 return -EINVAL;23432343 }23442344 }···23492349 if (netif_msg_probe(ugeth))23502350 ugeth_err23512351 ("%s: max_rx_buf_length must be non-zero multiple of 128.",23522352- __FUNCTION__);23522352+ __func__);23532353 return -EINVAL;23542354 }2355235523562356 /* num Tx queues */23572357 if (ug_info->numQueuesTx > NUM_TX_QUEUES) {23582358 if (netif_msg_probe(ugeth))23592359- ugeth_err("%s: number of tx queues too large.", __FUNCTION__);23592359+ ugeth_err("%s: number of tx queues too large.", __func__);23602360 return -EINVAL;23612361 }2362236223632363 /* num Rx queues */23642364 if (ug_info->numQueuesRx > NUM_RX_QUEUES) {23652365 if (netif_msg_probe(ugeth))23662366- ugeth_err("%s: number of rx queues too large.", __FUNCTION__);23662366+ ugeth_err("%s: number of rx queues too large.", __func__);23672367 return -EINVAL;23682368 }23692369···23742374 ugeth_err23752375 ("%s: VLAN priority table entry must not be"23762376 " larger than number of Rx queues.",23772377- __FUNCTION__);23772377+ __func__);23782378 return -EINVAL;23792379 }23802380 }···23862386 ugeth_err23872387 ("%s: IP priority table entry must not be"23882388 " larger than number of Rx queues.",23892389- __FUNCTION__);23892389+ __func__);23902390 return -EINVAL;23912391 }23922392 }···23942394 if (ug_info->cam && !ug_info->ecamptr) {23952395 if (netif_msg_probe(ugeth))23962396 ugeth_err("%s: If cam mode is chosen, must supply cam ptr.",23972397- __FUNCTION__);23972397+ __func__);23982398 return -EINVAL;23992399 }24002400···24042404 if (netif_msg_probe(ugeth))24052405 ugeth_err("%s: Number of station addresses greater than 1 "24062406 "not allowed in extended parsing mode.",24072407- __FUNCTION__);24072407+ __func__);24082408 return -EINVAL;24092409 }24102410···24182418 /* Initialize the general fast UCC block. */24192419 if (ucc_fast_init(uf_info, &ugeth->uccf)) {24202420 if (netif_msg_probe(ugeth))24212421- ugeth_err("%s: Failed to init uccf.", __FUNCTION__);24212421+ ugeth_err("%s: Failed to init uccf.", __func__);24222422 ucc_geth_memclean(ugeth);24232423 return -ENOMEM;24242424 }···24482448 u8 __iomem *endOfRing;24492449 u8 numThreadsRxNumerical, numThreadsTxNumerical;2450245024512451- ugeth_vdbg("%s: IN", __FUNCTION__);24512451+ ugeth_vdbg("%s: IN", __func__);24522452 uccf = ugeth->uccf;24532453 ug_info = ugeth->ug_info;24542454 uf_info = &ug_info->uf_info;···24742474 default:24752475 if (netif_msg_ifup(ugeth))24762476 ugeth_err("%s: Bad number of Rx threads value.",24772477- __FUNCTION__);24772477+ __func__);24782478 ucc_geth_memclean(ugeth);24792479 return -EINVAL;24802480 break;···24992499 default:25002500 if (netif_msg_ifup(ugeth))25012501 ugeth_err("%s: Bad number of Tx threads value.",25022502- __FUNCTION__);25022502+ __func__);25032503 ucc_geth_memclean(ugeth);25042504 return -EINVAL;25052505 break;···25532553 if (ret_val != 0) {25542554 if (netif_msg_ifup(ugeth))25552555 ugeth_err("%s: IPGIFG initialization parameter too large.",25562556- __FUNCTION__);25562556+ __func__);25572557 ucc_geth_memclean(ugeth);25582558 return ret_val;25592559 }···25712571 if (ret_val != 0) {25722572 if (netif_msg_ifup(ugeth))25732573 ugeth_err("%s: Half Duplex initialization parameter too large.",25742574- __FUNCTION__);25742574+ __func__);25752575 ucc_geth_memclean(ugeth);25762576 return ret_val;25772577 }···26262626 if (netif_msg_ifup(ugeth))26272627 ugeth_err26282628 ("%s: Can not allocate memory for Tx bd rings.",26292629- __FUNCTION__);26292629+ __func__);26302630 ucc_geth_memclean(ugeth);26312631 return -ENOMEM;26322632 }···26622662 if (netif_msg_ifup(ugeth))26632663 ugeth_err26642664 ("%s: Can not allocate memory for Rx bd rings.",26652665- __FUNCTION__);26652665+ __func__);26662666 ucc_geth_memclean(ugeth);26672667 return -ENOMEM;26682668 }···26782678 if (ugeth->tx_skbuff[j] == NULL) {26792679 if (netif_msg_ifup(ugeth))26802680 ugeth_err("%s: Could not allocate tx_skbuff",26812681- __FUNCTION__);26812681+ __func__);26822682 ucc_geth_memclean(ugeth);26832683 return -ENOMEM;26842684 }···27102710 if (ugeth->rx_skbuff[j] == NULL) {27112711 if (netif_msg_ifup(ugeth))27122712 ugeth_err("%s: Could not allocate rx_skbuff",27132713- __FUNCTION__);27132713+ __func__);27142714 ucc_geth_memclean(ugeth);27152715 return -ENOMEM;27162716 }···27442744 if (netif_msg_ifup(ugeth))27452745 ugeth_err27462746 ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.",27472747- __FUNCTION__);27472747+ __func__);27482748 ucc_geth_memclean(ugeth);27492749 return -ENOMEM;27502750 }···27672767 if (netif_msg_ifup(ugeth))27682768 ugeth_err27692769 ("%s: Can not allocate DPRAM memory for p_thread_data_tx.",27702770- __FUNCTION__);27702770+ __func__);27712771 ucc_geth_memclean(ugeth);27722772 return -ENOMEM;27732773 }···27972797 if (netif_msg_ifup(ugeth))27982798 ugeth_err27992799 ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.",28002800- __FUNCTION__);28002800+ __func__);28012801 ucc_geth_memclean(ugeth);28022802 return -ENOMEM;28032803 }···28412841 if (netif_msg_ifup(ugeth))28422842 ugeth_err28432843 ("%s: Can not allocate DPRAM memory for p_scheduler.",28442844- __FUNCTION__);28442844+ __func__);28452845 ucc_geth_memclean(ugeth);28462846 return -ENOMEM;28472847 }···28922892 ugeth_err28932893 ("%s: Can not allocate DPRAM memory for"28942894 " p_tx_fw_statistics_pram.",28952895- __FUNCTION__);28952895+ __func__);28962896 ucc_geth_memclean(ugeth);28972897 return -ENOMEM;28982898 }···29322932 if (netif_msg_ifup(ugeth))29332933 ugeth_err29342934 ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.",29352935- __FUNCTION__);29352935+ __func__);29362936 ucc_geth_memclean(ugeth);29372937 return -ENOMEM;29382938 }···29542954 if (netif_msg_ifup(ugeth))29552955 ugeth_err29562956 ("%s: Can not allocate DPRAM memory for p_thread_data_rx.",29572957- __FUNCTION__);29572957+ __func__);29582958 ucc_geth_memclean(ugeth);29592959 return -ENOMEM;29602960 }···29782978 if (netif_msg_ifup(ugeth))29792979 ugeth_err29802980 ("%s: Can not allocate DPRAM memory for"29812981- " p_rx_fw_statistics_pram.", __FUNCTION__);29812981+ " p_rx_fw_statistics_pram.", __func__);29822982 ucc_geth_memclean(ugeth);29832983 return -ENOMEM;29842984 }···30013001 if (netif_msg_ifup(ugeth))30023002 ugeth_err30033003 ("%s: Can not allocate DPRAM memory for"30043004- " p_rx_irq_coalescing_tbl.", __FUNCTION__);30043004+ " p_rx_irq_coalescing_tbl.", __func__);30053005 ucc_geth_memclean(ugeth);30063006 return -ENOMEM;30073007 }···30703070 if (netif_msg_ifup(ugeth))30713071 ugeth_err30723072 ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.",30733073- __FUNCTION__);30733073+ __func__);30743074 ucc_geth_memclean(ugeth);30753075 return -ENOMEM;30763076 }···31473147 if (!ug_info->extendedFilteringChainPointer) {31483148 if (netif_msg_ifup(ugeth))31493149 ugeth_err("%s: Null Extended Filtering Chain Pointer.",31503150- __FUNCTION__);31503150+ __func__);31513151 ucc_geth_memclean(ugeth);31523152 return -EINVAL;31533153 }···31613161 if (netif_msg_ifup(ugeth))31623162 ugeth_err31633163 ("%s: Can not allocate DPRAM memory for"31643164- " p_exf_glbl_param.", __FUNCTION__);31643164+ " p_exf_glbl_param.", __func__);31653165 ucc_geth_memclean(ugeth);31663166 return -ENOMEM;31673167 }···32093209 if (netif_msg_ifup(ugeth))32103210 ugeth_err32113211 ("%s: Can not allocate memory for"32123212- " p_UccInitEnetParamShadows.", __FUNCTION__);32123212+ " p_UccInitEnetParamShadows.", __func__);32133213 ucc_geth_memclean(ugeth);32143214 return -ENOMEM;32153215 }···32443244 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_16_BYTES)) {32453245 if (netif_msg_ifup(ugeth))32463246 ugeth_err("%s: Invalid largest External Lookup Key Size.",32473247- __FUNCTION__);32473247+ __func__);32483248 ucc_geth_memclean(ugeth);32493249 return -EINVAL;32503250 }···32713271 ug_info->riscRx, 1)) != 0) {32723272 if (netif_msg_ifup(ugeth))32733273 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",32743274- __FUNCTION__);32743274+ __func__);32753275 ucc_geth_memclean(ugeth);32763276 return ret_val;32773277 }···32873287 ug_info->riscTx, 0)) != 0) {32883288 if (netif_msg_ifup(ugeth))32893289 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",32903290- __FUNCTION__);32903290+ __func__);32913291 ucc_geth_memclean(ugeth);32923292 return ret_val;32933293 }···32973297 if ((ret_val = rx_bd_buffer_set(ugeth, (u8) i)) != 0) {32983298 if (netif_msg_ifup(ugeth))32993299 ugeth_err("%s: Can not fill Rx bds with buffers.",33003300- __FUNCTION__);33003300+ __func__);33013301 ucc_geth_memclean(ugeth);33023302 return ret_val;33033303 }···33093309 if (netif_msg_ifup(ugeth))33103310 ugeth_err33113311 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",33123312- __FUNCTION__);33123312+ __func__);33133313 ucc_geth_memclean(ugeth);33143314 return -ENOMEM;33153315 }···33603360{33613361 struct ucc_geth_private *ugeth = netdev_priv(dev);3362336233633363- ugeth_vdbg("%s: IN", __FUNCTION__);33633363+ ugeth_vdbg("%s: IN", __func__);3364336433653365 dev->stats.tx_errors++;33663366···33863386 u32 bd_status;33873387 u8 txQ = 0;3388338833893389- ugeth_vdbg("%s: IN", __FUNCTION__);33893389+ ugeth_vdbg("%s: IN", __func__);3390339033913391 spin_lock_irq(&ugeth->lock);33923392···34593459 u8 *bdBuffer;34603460 struct net_device *dev;3461346134623462- ugeth_vdbg("%s: IN", __FUNCTION__);34623462+ ugeth_vdbg("%s: IN", __func__);3463346334643464 dev = ugeth->dev;34653465···34813481 (bd_status & R_ERRORS_FATAL)) {34823482 if (netif_msg_rx_err(ugeth))34833483 ugeth_err("%s, %d: ERROR!!! skb - 0x%08x",34843484- __FUNCTION__, __LINE__, (u32) skb);34843484+ __func__, __LINE__, (u32) skb);34853485 if (skb)34863486 dev_kfree_skb_any(skb);34873487···35073507 skb = get_new_skb(ugeth, bd);35083508 if (!skb) {35093509 if (netif_msg_rx_err(ugeth))35103510- ugeth_warn("%s: No Rx Data Buffer", __FUNCTION__);35103510+ ugeth_warn("%s: No Rx Data Buffer", __func__);35113511 dev->stats.rx_dropped++;35123512 break;35133513 }···36133613 register u32 tx_mask;36143614 u8 i;3615361536163616- ugeth_vdbg("%s: IN", __FUNCTION__);36163616+ ugeth_vdbg("%s: IN", __func__);3617361736183618 uccf = ugeth->uccf;36193619 ug_info = ugeth->ug_info;···36833683 struct ucc_geth_private *ugeth = netdev_priv(dev);36843684 int err;3685368536863686- ugeth_vdbg("%s: IN", __FUNCTION__);36863686+ ugeth_vdbg("%s: IN", __func__);3687368736883688 /* Test station address */36893689 if (dev->dev_addr[0] & ENET_GROUP_ADDR) {36903690 if (netif_msg_ifup(ugeth))36913691 ugeth_err("%s: Multicast address used for station address"36923692- " - is this what you wanted?", __FUNCTION__);36923692+ " - is this what you wanted?", __func__);36933693 return -EINVAL;36943694 }36953695···37723772{37733773 struct ucc_geth_private *ugeth = netdev_priv(dev);3774377437753775- ugeth_vdbg("%s: IN", __FUNCTION__);37753775+ ugeth_vdbg("%s: IN", __func__);3776377637773777 napi_disable(&ugeth->napi);37783778···38403840 PHY_INTERFACE_MODE_TBI, PHY_INTERFACE_MODE_RTBI,38413841 };3842384238433843- ugeth_vdbg("%s: IN", __FUNCTION__);38433843+ ugeth_vdbg("%s: IN", __func__);3844384438453845 prop = of_get_property(np, "cell-index", NULL);38463846 if (!prop) {···38573857 if (ug_info == NULL) {38583858 if (netif_msg_probe(&debug))38593859 ugeth_err("%s: [%d] Missing additional data!",38603860- __FUNCTION__, ucc_num);38603860+ __func__, ucc_num);38613861 return -ENODEV;38623862 }38633863
+239-96
drivers/net/usb/hso.c
···92929393#define HSO_NET_TX_TIMEOUT (HZ*10)94949595-/* Serial port defines and structs. */9696-#define HSO_SERIAL_FLAG_RX_SENT 09797-9895#define HSO_SERIAL_MAGIC 0x48534f31999610097/* Number of ttys to handle */···176179 unsigned long flags;177180};178181182182+enum rx_ctrl_state{183183+ RX_IDLE,184184+ RX_SENT,185185+ RX_PENDING186186+};187187+179188struct hso_serial {180189 struct hso_device *parent;181190 int magic;···208205 struct usb_endpoint_descriptor *in_endp;209206 struct usb_endpoint_descriptor *out_endp;210207211211- unsigned long flags;208208+ enum rx_ctrl_state rx_state;212209 u8 rts_state;213210 u8 dtr_state;214211 unsigned tx_urb_used:1;···219216 spinlock_t serial_lock;220217221218 int (*write_data) (struct hso_serial *serial);219219+ /* Hacks required to get flow control220220+ * working on the serial receive buffers221221+ * so as not to drop characters on the floor.222222+ */223223+ int curr_rx_urb_idx;224224+ u16 curr_rx_urb_offset;225225+ u8 rx_urb_filled[MAX_RX_URBS];226226+ struct tasklet_struct unthrottle_tasklet;227227+ struct work_struct retry_unthrottle_workqueue;222228};223229224230struct hso_device {···283271static int hso_serial_tiocmset(struct tty_struct *tty, struct file *file,284272 unsigned int set, unsigned int clear);285273static void ctrl_callback(struct urb *urb);286286-static void put_rxbuf_data(struct urb *urb, struct hso_serial *serial);274274+static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial);287275static void hso_kick_transmit(struct hso_serial *serial);288276/* Helper functions */289277static int hso_mux_submit_intr_urb(struct hso_shared_int *mux_int,···299287static void hso_free_shared_int(struct hso_shared_int *shared_int);300288static int hso_stop_net_device(struct hso_device *hso_dev);301289static void hso_serial_ref_free(struct kref *ref);290290+static void hso_std_serial_read_bulk_callback(struct urb *urb);291291+static int hso_mux_serial_read(struct hso_serial *serial);302292static void async_get_intf(struct work_struct *data);303293static void async_put_intf(struct work_struct *data);304294static int hso_put_activity(struct hso_device *hso_dev);···471457 return sprintf(buf, "%s\n", port_name);472458}473459static DEVICE_ATTR(hsotype, S_IRUGO, hso_sysfs_show_porttype, NULL);460460+461461+static int hso_urb_to_index(struct hso_serial *serial, struct urb *urb)462462+{463463+ int idx;464464+465465+ for (idx = 0; idx < serial->num_rx_urbs; idx++)466466+ if (serial->rx_urb[idx] == urb)467467+ return idx;468468+ dev_err(serial->parent->dev, "hso_urb_to_index failed\n");469469+ return -1;470470+}474471475472/* converts mux value to a port spec value */476473static u32 hso_mux_to_port(int mux)···10641039 return;10651040}1066104110421042+static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb)10431043+{10441044+ int result;10451045+#ifdef CONFIG_HSO_AUTOPM10461046+ usb_mark_last_busy(urb->dev);10471047+#endif10481048+ /* We are done with this URB, resubmit it. Prep the USB to wait for10491049+ * another frame */10501050+ usb_fill_bulk_urb(urb, serial->parent->usb,10511051+ usb_rcvbulkpipe(serial->parent->usb,10521052+ serial->in_endp->10531053+ bEndpointAddress & 0x7F),10541054+ urb->transfer_buffer, serial->rx_data_length,10551055+ hso_std_serial_read_bulk_callback, serial);10561056+ /* Give this to the USB subsystem so it can tell us when more data10571057+ * arrives. */10581058+ result = usb_submit_urb(urb, GFP_ATOMIC);10591059+ if (result) {10601060+ dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n",10611061+ __func__, result);10621062+ }10631063+}10641064+10651065+10661066+10671067+10681068+static void put_rxbuf_data_and_resubmit_bulk_urb(struct hso_serial *serial)10691069+{10701070+ int count;10711071+ struct urb *curr_urb;10721072+10731073+ while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) {10741074+ curr_urb = serial->rx_urb[serial->curr_rx_urb_idx];10751075+ count = put_rxbuf_data(curr_urb, serial);10761076+ if (count == -1)10771077+ return;10781078+ if (count == 0) {10791079+ serial->curr_rx_urb_idx++;10801080+ if (serial->curr_rx_urb_idx >= serial->num_rx_urbs)10811081+ serial->curr_rx_urb_idx = 0;10821082+ hso_resubmit_rx_bulk_urb(serial, curr_urb);10831083+ }10841084+ }10851085+}10861086+10871087+static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)10881088+{10891089+ int count = 0;10901090+ struct urb *urb;10911091+10921092+ urb = serial->rx_urb[0];10931093+ if (serial->open_count > 0) {10941094+ count = put_rxbuf_data(urb, serial);10951095+ if (count == -1)10961096+ return;10971097+ }10981098+ /* Re issue a read as long as we receive data. */10991099+11001100+ if (count == 0 && ((urb->actual_length != 0) ||11011101+ (serial->rx_state == RX_PENDING))) {11021102+ serial->rx_state = RX_SENT;11031103+ hso_mux_serial_read(serial);11041104+ } else11051105+ serial->rx_state = RX_IDLE;11061106+}11071107+11081108+11091109+/* read callback for Diag and CS port */11101110+static void hso_std_serial_read_bulk_callback(struct urb *urb)11111111+{11121112+ struct hso_serial *serial = urb->context;11131113+ int status = urb->status;11141114+11151115+ /* sanity check */11161116+ if (!serial) {11171117+ D1("serial == NULL");11181118+ return;11191119+ } else if (status) {11201120+ log_usb_status(status, __func__);11211121+ return;11221122+ }11231123+11241124+ D4("\n--- Got serial_read_bulk callback %02x ---", status);11251125+ D1("Actual length = %d\n", urb->actual_length);11261126+ DUMP1(urb->transfer_buffer, urb->actual_length);11271127+11281128+ /* Anyone listening? */11291129+ if (serial->open_count == 0)11301130+ return;11311131+11321132+ if (status == 0) {11331133+ if (serial->parent->port_spec & HSO_INFO_CRC_BUG) {11341134+ u32 rest;11351135+ u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF };11361136+ rest =11371137+ urb->actual_length %11381138+ serial->in_endp->wMaxPacketSize;11391139+ if (((rest == 5) || (rest == 6))11401140+ && !memcmp(((u8 *) urb->transfer_buffer) +11411141+ urb->actual_length - 4, crc_check, 4)) {11421142+ urb->actual_length -= 4;11431143+ }11441144+ }11451145+ /* Valid data, handle RX data */11461146+ spin_lock(&serial->serial_lock);11471147+ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1;11481148+ put_rxbuf_data_and_resubmit_bulk_urb(serial);11491149+ spin_unlock(&serial->serial_lock);11501150+ } else if (status == -ENOENT || status == -ECONNRESET) {11511151+ /* Unlinked - check for throttled port. */11521152+ D2("Port %d, successfully unlinked urb", serial->minor);11531153+ spin_lock(&serial->serial_lock);11541154+ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0;11551155+ hso_resubmit_rx_bulk_urb(serial, urb);11561156+ spin_unlock(&serial->serial_lock);11571157+ } else {11581158+ D2("Port %d, status = %d for read urb", serial->minor, status);11591159+ return;11601160+ }11611161+}11621162+11631163+/*11641164+ * This needs to be a tasklet otherwise we will11651165+ * end up recursively calling this function.11661166+ */11671167+void hso_unthrottle_tasklet(struct hso_serial *serial)11681168+{11691169+ unsigned long flags;11701170+11711171+ spin_lock_irqsave(&serial->serial_lock, flags);11721172+ if ((serial->parent->port_spec & HSO_INTF_MUX))11731173+ put_rxbuf_data_and_resubmit_ctrl_urb(serial);11741174+ else11751175+ put_rxbuf_data_and_resubmit_bulk_urb(serial);11761176+ spin_unlock_irqrestore(&serial->serial_lock, flags);11771177+}11781178+11791179+static void hso_unthrottle(struct tty_struct *tty)11801180+{11811181+ struct hso_serial *serial = get_serial_by_tty(tty);11821182+11831183+ tasklet_hi_schedule(&serial->unthrottle_tasklet);11841184+}11851185+11861186+void hso_unthrottle_workfunc(struct work_struct *work)11871187+{11881188+ struct hso_serial *serial =11891189+ container_of(work, struct hso_serial,11901190+ retry_unthrottle_workqueue);11911191+ hso_unthrottle_tasklet(serial);11921192+}11931193+10671194/* open the requested serial port */10681195static int hso_serial_open(struct tty_struct *tty, struct file *filp)10691196{···12411064 tty->driver_data = serial;12421065 serial->tty = tty;1243106612441244- /* check for port allready opened, if not set the termios */10671067+ /* check for port already opened, if not set the termios */12451068 serial->open_count++;12461069 if (serial->open_count == 1) {12471070 tty->low_latency = 1;12481248- serial->flags = 0;10711071+ serial->rx_state = RX_IDLE;12491072 /* Force default termio settings */12501073 _hso_serial_set_termios(tty, NULL);10741074+ tasklet_init(&serial->unthrottle_tasklet,10751075+ (void (*)(unsigned long))hso_unthrottle_tasklet,10761076+ (unsigned long)serial);10771077+ INIT_WORK(&serial->retry_unthrottle_workqueue,10781078+ hso_unthrottle_workfunc);12511079 result = hso_start_serial_device(serial->parent, GFP_KERNEL);12521080 if (result) {12531081 hso_stop_serial_device(serial->parent);···12991117 }13001118 if (!usb_gone)13011119 hso_stop_serial_device(serial->parent);11201120+ tasklet_kill(&serial->unthrottle_tasklet);11211121+ cancel_work_sync(&serial->retry_unthrottle_workqueue);13021122 }11231123+13031124 if (!usb_gone)13041125 usb_autopm_put_interface(serial->parent->interface);11261126+13051127 mutex_unlock(&serial->parent->mutex);13061128}13071129···16081422 (1 << i));16091423 if (serial != NULL) {16101424 D1("Pending read interrupt on port %d\n", i);16111611- if (!test_and_set_bit(HSO_SERIAL_FLAG_RX_SENT,16121612- &serial->flags)) {14251425+ spin_lock(&serial->serial_lock);14261426+ if (serial->rx_state == RX_IDLE) {16131427 /* Setup and send a ctrl req read on16141428 * port i */16151615- hso_mux_serial_read(serial);14291429+ if (!serial->rx_urb_filled[0]) {14301430+ serial->rx_state = RX_SENT;14311431+ hso_mux_serial_read(serial);14321432+ } else14331433+ serial->rx_state = RX_PENDING;14341434+16161435 } else {16171436 D1("Already pending a read on "16181437 "port %d\n", i);16191438 }14391439+ spin_unlock(&serial->serial_lock);16201440 }16211441 }16221442 }···17241532 if (req->bRequestType ==17251533 (USB_DIR_IN | USB_TYPE_OPTION_VENDOR | USB_RECIP_INTERFACE)) {17261534 /* response to a read command */17271727- if (serial->open_count > 0) {17281728- /* handle RX data the normal way */17291729- put_rxbuf_data(urb, serial);17301730- }17311731-17321732- /* Re issue a read as long as we receive data. */17331733- if (urb->actual_length != 0)17341734- hso_mux_serial_read(serial);17351735- else17361736- clear_bit(HSO_SERIAL_FLAG_RX_SENT, &serial->flags);15351535+ serial->rx_urb_filled[0] = 1;15361536+ spin_lock(&serial->serial_lock);15371537+ put_rxbuf_data_and_resubmit_ctrl_urb(serial);15381538+ spin_unlock(&serial->serial_lock);17371539 } else {17381540 hso_put_activity(serial->parent);17391541 if (serial->tty)···17381552}1739155317401554/* handle RX data for serial port */17411741-static void put_rxbuf_data(struct urb *urb, struct hso_serial *serial)15551555+static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)17421556{17431557 struct tty_struct *tty = serial->tty;17441744-15581558+ int write_length_remaining = 0;15591559+ int curr_write_len;17451560 /* Sanity check */17461561 if (urb == NULL || serial == NULL) {17471562 D1("serial = NULL");17481748- return;15631563+ return -2;17491564 }1750156517511566 /* Push data to tty */17521752- if (tty && urb->actual_length) {15671567+ if (tty) {15681568+ write_length_remaining = urb->actual_length -15691569+ serial->curr_rx_urb_offset;17531570 D1("data to push to tty");17541754- tty_insert_flip_string(tty, urb->transfer_buffer,17551755- urb->actual_length);17561756- tty_flip_buffer_push(tty);17571757- }17581758-}17591759-17601760-/* read callback for Diag and CS port */17611761-static void hso_std_serial_read_bulk_callback(struct urb *urb)17621762-{17631763- struct hso_serial *serial = urb->context;17641764- int result;17651765- int status = urb->status;17661766-17671767- /* sanity check */17681768- if (!serial) {17691769- D1("serial == NULL");17701770- return;17711771- } else if (status) {17721772- log_usb_status(status, __func__);17731773- return;17741774- }17751775-17761776- D4("\n--- Got serial_read_bulk callback %02x ---", status);17771777- D1("Actual length = %d\n", urb->actual_length);17781778- DUMP1(urb->transfer_buffer, urb->actual_length);17791779-17801780- /* Anyone listening? */17811781- if (serial->open_count == 0)17821782- return;17831783-17841784- if (status == 0) {17851785- if (serial->parent->port_spec & HSO_INFO_CRC_BUG) {17861786- u32 rest;17871787- u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF };17881788- rest =17891789- urb->actual_length %17901790- serial->in_endp->wMaxPacketSize;17911791- if (((rest == 5) || (rest == 6))17921792- && !memcmp(((u8 *) urb->transfer_buffer) +17931793- urb->actual_length - 4, crc_check, 4)) {17941794- urb->actual_length -= 4;17951795- }15711571+ while (write_length_remaining) {15721572+ if (test_bit(TTY_THROTTLED, &tty->flags))15731573+ return -1;15741574+ curr_write_len = tty_insert_flip_string15751575+ (tty, urb->transfer_buffer +15761576+ serial->curr_rx_urb_offset,15771577+ write_length_remaining);15781578+ serial->curr_rx_urb_offset += curr_write_len;15791579+ write_length_remaining -= curr_write_len;15801580+ tty_flip_buffer_push(tty);17961581 }17971797- /* Valid data, handle RX data */17981798- put_rxbuf_data(urb, serial);17991799- } else if (status == -ENOENT || status == -ECONNRESET) {18001800- /* Unlinked - check for throttled port. */18011801- D2("Port %d, successfully unlinked urb", serial->minor);18021802- } else {18031803- D2("Port %d, status = %d for read urb", serial->minor, status);18041804- return;18051582 }18061806-18071807- usb_mark_last_busy(urb->dev);18081808-18091809- /* We are done with this URB, resubmit it. Prep the USB to wait for18101810- * another frame */18111811- usb_fill_bulk_urb(urb, serial->parent->usb,18121812- usb_rcvbulkpipe(serial->parent->usb,18131813- serial->in_endp->18141814- bEndpointAddress & 0x7F),18151815- urb->transfer_buffer, serial->rx_data_length,18161816- hso_std_serial_read_bulk_callback, serial);18171817- /* Give this to the USB subsystem so it can tell us when more data18181818- * arrives. */18191819- result = usb_submit_urb(urb, GFP_ATOMIC);18201820- if (result) {18211821- dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d",18221822- __func__, result);15831583+ if (write_length_remaining == 0) {15841584+ serial->curr_rx_urb_offset = 0;15851585+ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0;18231586 }15871587+ return write_length_remaining;18241588}15891589+1825159018261591/* Base driver functions */18271592···19311794 return -ENODEV;1932179519331796 for (i = 0; i < serial->num_rx_urbs; i++) {19341934- if (serial->rx_urb[i])17971797+ if (serial->rx_urb[i]) {19351798 usb_kill_urb(serial->rx_urb[i]);17991799+ serial->rx_urb_filled[i] = 0;18001800+ }19361801 }18021802+ serial->curr_rx_urb_idx = 0;18031803+ serial->curr_rx_urb_offset = 0;1937180419381805 if (serial->tx_urb)19391806 usb_kill_urb(serial->tx_urb);···23522211 USB_DIR_IN);23532212 if (!serial->in_endp) {23542213 dev_err(&interface->dev, "Failed to find BULK IN ep\n");23552355- goto exit;22142214+ goto exit2;23562215 }2357221623582217 if (!23592218 (serial->out_endp =23602219 hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {23612220 dev_err(&interface->dev, "Failed to find BULK IN ep\n");23622362- goto exit;22212221+ goto exit2;23632222 }2364222323652224 serial->write_data = hso_std_serial_write_data;···2372223123732232 /* done, return it */23742233 return hso_dev;22342234+22352235+exit2:22362236+ hso_serial_common_free(serial);23752237exit:23762376- if (hso_dev && serial)23772377- hso_serial_common_free(serial);23782238 kfree(serial);23792239 hso_free_device(hso_dev);23802240 return NULL;···28822740 .chars_in_buffer = hso_serial_chars_in_buffer,28832741 .tiocmget = hso_serial_tiocmget,28842742 .tiocmset = hso_serial_tiocmset,27432743+ .unthrottle = hso_unthrottle28852744};2886274528872746static struct usb_driver hso_driver = {
+1-1
drivers/net/usb/mcs7830.c
···118118119119 if (urb->status < 0)120120 printk(KERN_DEBUG "%s() failed with %d\n",121121- __FUNCTION__, urb->status);121121+ __func__, urb->status);122122123123 kfree(req);124124 usb_free_urb(urb);
+10-10
drivers/net/usb/pegasus.c
···119119 default:120120 if (netif_msg_drv(pegasus) && printk_ratelimit())121121 dev_dbg(&pegasus->intf->dev, "%s, status %d\n",122122- __FUNCTION__, urb->status);122122+ __func__, urb->status);123123 }124124 pegasus->flags &= ~ETH_REGS_CHANGED;125125 wake_up(&pegasus->ctrl_wait);···136136 if (!buffer) {137137 if (netif_msg_drv(pegasus))138138 dev_warn(&pegasus->intf->dev, "out of memory in %s\n",139139- __FUNCTION__);139139+ __func__);140140 return -ENOMEM;141141 }142142 add_wait_queue(&pegasus->ctrl_wait, &wait);···224224 netif_device_detach(pegasus->net);225225 if (netif_msg_drv(pegasus))226226 dev_err(&pegasus->intf->dev, "%s, status %d\n",227227- __FUNCTION__, ret);227227+ __func__, ret);228228 goto out;229229 }230230···246246 if (!tmp) {247247 if (netif_msg_drv(pegasus))248248 dev_warn(&pegasus->intf->dev, "out of memory in %s\n",249249- __FUNCTION__);249249+ __func__);250250 return -ENOMEM;251251 }252252 memcpy(tmp, &data, 1);···277277 netif_device_detach(pegasus->net);278278 if (netif_msg_drv(pegasus) && printk_ratelimit())279279 dev_err(&pegasus->intf->dev, "%s, status %d\n",280280- __FUNCTION__, ret);280280+ __func__, ret);281281 goto out;282282 }283283···310310 netif_device_detach(pegasus->net);311311 if (netif_msg_drv(pegasus))312312 dev_err(&pegasus->intf->dev, "%s, status %d\n",313313- __FUNCTION__, ret);313313+ __func__, ret);314314 }315315316316 return ret;···341341 }342342fail:343343 if (netif_msg_drv(pegasus))344344- dev_warn(&pegasus->intf->dev, "%s failed\n", __FUNCTION__);344344+ dev_warn(&pegasus->intf->dev, "%s failed\n", __func__);345345346346 return ret;347347}···378378379379fail:380380 if (netif_msg_drv(pegasus))381381- dev_warn(&pegasus->intf->dev, "%s failed\n", __FUNCTION__);381381+ dev_warn(&pegasus->intf->dev, "%s failed\n", __func__);382382 return -ETIMEDOUT;383383}384384···415415416416fail:417417 if (netif_msg_drv(pegasus))418418- dev_warn(&pegasus->intf->dev, "%s failed\n", __FUNCTION__);418418+ dev_warn(&pegasus->intf->dev, "%s failed\n", __func__);419419 return -ETIMEDOUT;420420}421421···463463 return ret;464464fail:465465 if (netif_msg_drv(pegasus))466466- dev_warn(&pegasus->intf->dev, "%s failed\n", __FUNCTION__);466466+ dev_warn(&pegasus->intf->dev, "%s failed\n", __func__);467467 return -ETIMEDOUT;468468}469469#endif /* PEGASUS_WRITE_EEPROM */