diff options
Diffstat (limited to 'drivers/net/cxgb3')
-rw-r--r-- | drivers/net/cxgb3/adapter.h | 2 | ||||
-rw-r--r-- | drivers/net/cxgb3/common.h | 3 | ||||
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 252 | ||||
-rw-r--r-- | drivers/net/cxgb3/cxgb3_offload.c | 16 | ||||
-rw-r--r-- | drivers/net/cxgb3/cxgb3_offload.h | 2 | ||||
-rw-r--r-- | drivers/net/cxgb3/sge.c | 23 | ||||
-rw-r--r-- | drivers/net/cxgb3/t3_hw.c | 46 | ||||
-rw-r--r-- | drivers/net/cxgb3/t3cdev.h | 3 |
8 files changed, 227 insertions, 120 deletions
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h index ab72563b81ee..20e887de2545 100644 --- a/drivers/net/cxgb3/adapter.h +++ b/drivers/net/cxgb3/adapter.h @@ -50,7 +50,9 @@ typedef irqreturn_t(*intr_handler_t) (int, void *); struct vlan_group; +struct adapter; struct port_info { + struct adapter *adapter; struct vlan_group *vlan_grp; const struct port_type_info *port_type; u8 port_id; diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h index 16378004507a..2129210a67c1 100644 --- a/drivers/net/cxgb3/common.h +++ b/drivers/net/cxgb3/common.h @@ -679,7 +679,8 @@ const struct adapter_info *t3_get_adapter_info(unsigned int board_id); int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data); int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data); int t3_seeprom_wp(struct adapter *adapter, int enable); -int t3_check_tpsram_version(struct adapter *adapter); +int t3_get_tp_version(struct adapter *adapter, u32 *vers); +int t3_check_tpsram_version(struct adapter *adapter, int *must_load); int t3_check_tpsram(struct adapter *adapter, u8 *tp_ram, unsigned int size); int t3_set_proto_sram(struct adapter *adap, u8 *data); int t3_read_flash(struct adapter *adapter, unsigned int addr, diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index dc5d26988bb3..5ab319cfe5de 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c @@ -358,11 +358,14 @@ static int init_dummy_netdevs(struct adapter *adap) for (j = 0; j < pi->nqsets - 1; j++) { if (!adap->dummy_netdev[dummy_idx]) { - nd = alloc_netdev(0, "", ether_setup); + struct port_info *p; + + nd = alloc_netdev(sizeof(*p), "", ether_setup); if (!nd) goto free_all; - nd->priv = adap; + p = netdev_priv(nd); + p->adapter = adap; nd->weight = 64; set_bit(__LINK_STATE_START, &nd->state); adap->dummy_netdev[dummy_idx] = nd; @@ -482,7 +485,8 @@ static ssize_t attr_store(struct device *d, struct device_attribute *attr, #define CXGB3_SHOW(name, val_expr) \ static ssize_t format_##name(struct net_device *dev, char *buf) \ { \ - struct adapter *adap = dev->priv; \ + struct port_info *pi = netdev_priv(dev); \ + struct adapter *adap = pi->adapter; \ return sprintf(buf, "%u\n", val_expr); \ } \ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ @@ -493,7 +497,8 @@ static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ static ssize_t set_nfilters(struct net_device *dev, unsigned int val) { - struct adapter *adap = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adap = pi->adapter; int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; if (adap->flags & FULL_INIT_DONE) @@ -515,7 +520,8 @@ static ssize_t store_nfilters(struct device *d, struct device_attribute *attr, static ssize_t set_nservers(struct net_device *dev, unsigned int val) { - struct adapter *adap = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adap = pi->adapter; if (adap->flags & FULL_INIT_DONE) return -EBUSY; @@ -556,9 +562,10 @@ static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs }; static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, char *buf, int sched) { - ssize_t len; + struct port_info *pi = netdev_priv(to_net_dev(d)); + struct adapter *adap = pi->adapter; unsigned int v, addr, bpt, cpt; - struct adapter *adap = to_net_dev(d)->priv; + ssize_t len; addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; rtnl_lock(); @@ -581,10 +588,11 @@ static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, const char *buf, size_t len, int sched) { + struct port_info *pi = netdev_priv(to_net_dev(d)); + struct adapter *adap = pi->adapter; + unsigned int val; char *endp; ssize_t ret; - unsigned int val; - struct adapter *adap = to_net_dev(d)->priv; if (!capable(CAP_NET_ADMIN)) return -EPERM; @@ -721,6 +729,7 @@ static void bind_qsets(struct adapter *adap) } #define FW_FNAME "t3fw-%d.%d.%d.bin" +#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin" static int upgrade_fw(struct adapter *adap) { @@ -739,6 +748,71 @@ static int upgrade_fw(struct adapter *adap) } ret = t3_load_fw(adap, fw->data, fw->size); release_firmware(fw); + + if (ret == 0) + dev_info(dev, "successful upgrade to firmware %d.%d.%d\n", + FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO); + else + dev_err(dev, "failed to upgrade to firmware %d.%d.%d\n", + FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO); + + return ret; +} + +static inline char t3rev2char(struct adapter *adapter) +{ + char rev = 0; + + switch(adapter->params.rev) { + case T3_REV_B: + case T3_REV_B2: + rev = 'b'; + break; + } + return rev; +} + +int update_tpsram(struct adapter *adap) +{ + const struct firmware *tpsram; + char buf[64]; + struct device *dev = &adap->pdev->dev; + int ret; + char rev; + + rev = t3rev2char(adap); + if (!rev) + return 0; + + snprintf(buf, sizeof(buf), TPSRAM_NAME, rev, + TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO); + + ret = request_firmware(&tpsram, buf, dev); + if (ret < 0) { + dev_err(dev, "could not load TP SRAM: unable to load %s\n", + buf); + return ret; + } + + ret = t3_check_tpsram(adap, tpsram->data, tpsram->size); + if (ret) + goto release_tpsram; + + ret = t3_set_proto_sram(adap, tpsram->data); + if (ret == 0) + dev_info(dev, + "successful update of protocol engine " + "to %d.%d.%d\n", + TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO); + else + dev_err(dev, "failed to update of protocol engine %d.%d.%d\n", + TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO); + if (ret) + dev_err(dev, "loading protocol SRAM failed\n"); + +release_tpsram: + release_firmware(tpsram); + return ret; } @@ -755,6 +829,7 @@ static int upgrade_fw(struct adapter *adap) static int cxgb_up(struct adapter *adap) { int err = 0; + int must_load; if (!(adap->flags & FULL_INIT_DONE)) { err = t3_check_fw_version(adap); @@ -763,6 +838,13 @@ static int cxgb_up(struct adapter *adap) if (err) goto out; + err = t3_check_tpsram_version(adap, &must_load); + if (err == -EINVAL) { + err = update_tpsram(adap); + if (err && must_load) + goto out; + } + err = init_dummy_netdevs(adap); if (err) goto out; @@ -858,8 +940,9 @@ static void schedule_chk_task(struct adapter *adap) static int offload_open(struct net_device *dev) { - struct adapter *adapter = dev->priv; - struct t3cdev *tdev = T3CDEV(dev); + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; + struct t3cdev *tdev = dev2t3cdev(dev); int adap_up = adapter->open_device_map & PORT_MASK; int err = 0; @@ -924,10 +1007,10 @@ static int offload_close(struct t3cdev *tdev) static int cxgb_open(struct net_device *dev) { - int err; - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; int other_ports = adapter->open_device_map & PORT_MASK; + int err; if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) return err; @@ -951,17 +1034,17 @@ static int cxgb_open(struct net_device *dev) static int cxgb_close(struct net_device *dev) { - struct adapter *adapter = dev->priv; - struct port_info *p = netdev_priv(dev); + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; - t3_port_intr_disable(adapter, p->port_id); + t3_port_intr_disable(adapter, pi->port_id); netif_stop_queue(dev); - p->phy.ops->power_down(&p->phy, 1); + pi->phy.ops->power_down(&pi->phy, 1); netif_carrier_off(dev); - t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); + t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); spin_lock(&adapter->work_lock); /* sync with update task */ - clear_bit(p->port_id, &adapter->open_device_map); + clear_bit(pi->port_id, &adapter->open_device_map); spin_unlock(&adapter->work_lock); if (!(adapter->open_device_map & PORT_MASK)) @@ -976,13 +1059,13 @@ static int cxgb_close(struct net_device *dev) static struct net_device_stats *cxgb_get_stats(struct net_device *dev) { - struct adapter *adapter = dev->priv; - struct port_info *p = netdev_priv(dev); - struct net_device_stats *ns = &p->netstats; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; + struct net_device_stats *ns = &pi->netstats; const struct mac_stats *pstats; spin_lock(&adapter->stats_lock); - pstats = t3_mac_update_stats(&p->mac); + pstats = t3_mac_update_stats(&pi->mac); spin_unlock(&adapter->stats_lock); ns->tx_bytes = pstats->tx_octets; @@ -1015,14 +1098,16 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev) static u32 get_msglevel(struct net_device *dev) { - struct adapter *adapter = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; return adapter->msg_enable; } static void set_msglevel(struct net_device *dev, u32 val) { - struct adapter *adapter = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; adapter->msg_enable = val; } @@ -1096,10 +1181,13 @@ static int get_eeprom_len(struct net_device *dev) static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; u32 fw_vers = 0; - struct adapter *adapter = dev->priv; + u32 tp_vers = 0; t3_get_fw_version(adapter, &fw_vers); + t3_get_tp_version(adapter, &tp_vers); strcpy(info->driver, DRV_NAME); strcpy(info->version, DRV_VERSION); @@ -1108,11 +1196,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) strcpy(info->fw_version, "N/A"); else { snprintf(info->fw_version, sizeof(info->fw_version), - "%s %u.%u.%u", + "%s %u.%u.%u TP %u.%u.%u", G_FW_VERSION_TYPE(fw_vers) ? "T" : "N", G_FW_VERSION_MAJOR(fw_vers), G_FW_VERSION_MINOR(fw_vers), - G_FW_VERSION_MICRO(fw_vers)); + G_FW_VERSION_MICRO(fw_vers), + G_TP_VERSION_MAJOR(tp_vers), + G_TP_VERSION_MINOR(tp_vers), + G_TP_VERSION_MICRO(tp_vers)); } } @@ -1136,8 +1227,8 @@ static unsigned long collect_sge_port_stats(struct adapter *adapter, static void get_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data) { - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; const struct mac_stats *s; spin_lock(&adapter->stats_lock); @@ -1205,7 +1296,8 @@ static inline void reg_block_dump(struct adapter *ap, void *buf, static void get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) { - struct adapter *ap = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *ap = pi->adapter; /* * Version scheme: @@ -1246,8 +1338,9 @@ static int restart_autoneg(struct net_device *dev) static int cxgb3_phys_id(struct net_device *dev, u32 data) { + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; int i; - struct adapter *adapter = dev->priv; if (data == 0) data = 2; @@ -1408,8 +1501,8 @@ static int set_rx_csum(struct net_device *dev, u32 data) static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) { - const struct adapter *adapter = dev->priv; - const struct port_info *pi = netdev_priv(dev); + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; e->rx_max_pending = MAX_RX_BUFFERS; @@ -1425,10 +1518,10 @@ static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) { - int i; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; struct qset_params *q; - struct adapter *adapter = dev->priv; - const struct port_info *pi = netdev_priv(dev); + int i; if (e->rx_pending > MAX_RX_BUFFERS || e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || @@ -1457,7 +1550,8 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) { - struct adapter *adapter = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; struct qset_params *qsp = &adapter->params.sge.qset[0]; struct sge_qset *qs = &adapter->sge.qs[0]; @@ -1471,7 +1565,8 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) { - struct adapter *adapter = dev->priv; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; struct qset_params *q = adapter->params.sge.qset; c->rx_coalesce_usecs = q->coalesce_usecs; @@ -1481,8 +1576,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, u8 * data) { + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; int i, err = 0; - struct adapter *adapter = dev->priv; u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); if (!buf) @@ -1501,10 +1597,11 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 * data) { + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; + u32 aligned_offset, aligned_len, *p; u8 *buf; int err = 0; - u32 aligned_offset, aligned_len, *p; - struct adapter *adapter = dev->priv; if (eeprom->magic != EEPROM_MAGIC) return -EINVAL; @@ -1592,9 +1689,10 @@ static int in_range(int val, int lo, int hi) static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) { - int ret; + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; u32 cmd; - struct adapter *adapter = dev->priv; + int ret; if (copy_from_user(&cmd, useraddr, sizeof(cmd))) return -EFAULT; @@ -1923,10 +2021,10 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) { - int ret, mmd; - struct adapter *adapter = dev->priv; - struct port_info *pi = netdev_priv(dev); struct mii_ioctl_data *data = if_mii(req); + struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; + int ret, mmd; switch (cmd) { case SIOCGMIIPHY: @@ -1994,9 +2092,9 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) static int cxgb_change_mtu(struct net_device *dev, int new_mtu) { - int ret; - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; + int ret; if (new_mtu < 81) /* accommodate SACK */ return -EINVAL; @@ -2013,8 +2111,8 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu) static int cxgb_set_mac_addr(struct net_device *dev, void *p) { - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) @@ -2050,8 +2148,8 @@ static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p) static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) { - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; pi->vlan_grp = grp; if (adapter->params.rev > 0) @@ -2070,8 +2168,8 @@ static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) #ifdef CONFIG_NET_POLL_CONTROLLER static void cxgb_netpoll(struct net_device *dev) { - struct adapter *adapter = dev->priv; struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; int qidx; for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { @@ -2088,42 +2186,6 @@ static void cxgb_netpoll(struct net_device *dev) } #endif -#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin" -int update_tpsram(struct adapter *adap) -{ - const struct firmware *tpsram; - char buf[64]; - struct device *dev = &adap->pdev->dev; - int ret; - char rev; - - rev = adap->params.rev == T3_REV_B2 ? 'b' : 'a'; - - snprintf(buf, sizeof(buf), TPSRAM_NAME, rev, - TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO); - - ret = request_firmware(&tpsram, buf, dev); - if (ret < 0) { - dev_err(dev, "could not load TP SRAM: unable to load %s\n", - buf); - return ret; - } - - ret = t3_check_tpsram(adap, tpsram->data, tpsram->size); - if (ret) - goto release_tpsram; - - ret = t3_set_proto_sram(adap, tpsram->data); - if (ret) - dev_err(dev, "loading protocol SRAM failed\n"); - -release_tpsram: - release_firmware(tpsram); - - return ret; -} - - /* * Periodic accumulation of MAC statistics. */ @@ -2433,6 +2495,7 @@ static int __devinit init_one(struct pci_dev *pdev, adapter->port[i] = netdev; pi = netdev_priv(netdev); + pi->adapter = adapter; pi->rx_csum_offload = 1; pi->nqsets = 1; pi->first_qset = i; @@ -2442,7 +2505,6 @@ static int __devinit init_one(struct pci_dev *pdev, netdev->irq = pdev->irq; netdev->mem_start = mmio_start; netdev->mem_end = mmio_start + mmio_len - 1; - netdev->priv = adapter; netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; netdev->features |= NETIF_F_LLTX; if (pci_using_dac) @@ -2467,18 +2529,11 @@ static int __devinit init_one(struct pci_dev *pdev, SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); } - pci_set_drvdata(pdev, adapter->port[0]); + pci_set_drvdata(pdev, adapter); if (t3_prep_adapter(adapter, ai, 1) < 0) { err = -ENODEV; goto out_free_dev; } - - err = t3_check_tpsram_version(adapter); - if (err == -EINVAL) - err = update_tpsram(adapter); - - if (err) - goto out_free_dev; /* * The card is now ready to go. If any errors occur during device @@ -2547,11 +2602,10 @@ out_release_regions: static void __devexit remove_one(struct pci_dev *pdev) { - struct net_device *dev = pci_get_drvdata(pdev); + struct adapter *adapter = pci_get_drvdata(pdev); - if (dev) { + if (adapter) { int i; - struct adapter *adapter = dev->priv; t3_sge_stop(adapter); sysfs_remove_group(&adapter->port[0]->dev.kobj, diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c index e620ed4c3ff0..bdff7baeb59d 100644 --- a/drivers/net/cxgb3/cxgb3_offload.c +++ b/drivers/net/cxgb3/cxgb3_offload.c @@ -593,6 +593,16 @@ int cxgb3_alloc_stid(struct t3cdev *tdev, struct cxgb3_client *client, EXPORT_SYMBOL(cxgb3_alloc_stid); +/* Get the t3cdev associated with a net_device */ +struct t3cdev *dev2t3cdev(struct net_device *dev) +{ + const struct port_info *pi = netdev_priv(dev); + + return (struct t3cdev *)pi->adapter; +} + +EXPORT_SYMBOL(dev2t3cdev); + static int do_smt_write_rpl(struct t3cdev *dev, struct sk_buff *skb) { struct cpl_smt_write_rpl *rpl = cplhdr(skb); @@ -925,7 +935,7 @@ void cxgb_neigh_update(struct neighbour *neigh) struct net_device *dev = neigh->dev; if (dev && (is_offloading(dev))) { - struct t3cdev *tdev = T3CDEV(dev); + struct t3cdev *tdev = dev2t3cdev(dev); BUG_ON(!tdev); t3_l2t_update(tdev, neigh); @@ -973,9 +983,9 @@ void cxgb_redirect(struct dst_entry *old, struct dst_entry *new) "device ignored.\n", __FUNCTION__); return; } - tdev = T3CDEV(olddev); + tdev = dev2t3cdev(olddev); BUG_ON(!tdev); - if (tdev != T3CDEV(newdev)) { + if (tdev != dev2t3cdev(newdev)) { printk(KERN_WARNING "%s: Redirect to different " "offload device ignored.\n", __FUNCTION__); return; diff --git a/drivers/net/cxgb3/cxgb3_offload.h b/drivers/net/cxgb3/cxgb3_offload.h index f15446a32efc..7a379138b5a6 100644 --- a/drivers/net/cxgb3/cxgb3_offload.h +++ b/drivers/net/cxgb3/cxgb3_offload.h @@ -51,6 +51,8 @@ void cxgb3_offload_deactivate(struct adapter *adapter); void cxgb3_set_dummy_ops(struct t3cdev *dev); +struct t3cdev *dev2t3cdev(struct net_device *dev); + /* * Client registration. Users of T3 driver must register themselves. * The T3 driver will call the add function of every client for each T3 diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c index a2cfd68ac757..58a5f60521ed 100644 --- a/drivers/net/cxgb3/sge.c +++ b/drivers/net/cxgb3/sge.c @@ -1073,7 +1073,7 @@ int t3_eth_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned int ndesc, pidx, credits, gen, compl; const struct port_info *pi = netdev_priv(dev); - struct adapter *adap = dev->priv; + struct adapter *adap = pi->adapter; struct sge_qset *qs = dev2qset(dev); struct sge_txq *q = &qs->txq[TXQ_ETH]; @@ -1326,7 +1326,8 @@ static void restart_ctrlq(unsigned long data) struct sk_buff *skb; struct sge_qset *qs = (struct sge_qset *)data; struct sge_txq *q = &qs->txq[TXQ_CTRL]; - struct adapter *adap = qs->netdev->priv; + const struct port_info *pi = netdev_priv(qs->netdev); + struct adapter *adap = pi->adapter; spin_lock(&q->lock); again:reclaim_completed_tx_imm(q); @@ -1531,7 +1532,8 @@ static void restart_offloadq(unsigned long data) struct sk_buff *skb; struct sge_qset *qs = (struct sge_qset *)data; struct sge_txq *q = &qs->txq[TXQ_OFLD]; - struct adapter *adap = qs->netdev->priv; + const struct port_info *pi = netdev_priv(qs->netdev); + struct adapter *adap = pi->adapter; spin_lock(&q->lock); again:reclaim_completed_tx(adap, q); @@ -1675,7 +1677,8 @@ static inline void deliver_partial_bundle(struct t3cdev *tdev, */ static int ofld_poll(struct net_device *dev, int *budget) { - struct adapter *adapter = dev->priv; + const struct port_info *pi = netdev_priv(dev); + struct adapter *adapter = pi->adapter; struct sge_qset *qs = dev2qset(dev); struct sge_rspq *q = &qs->rspq; int work_done, limit = min(*budget, dev->quota), avail = limit; @@ -2075,7 +2078,8 @@ static inline int is_pure_response(const struct rsp_desc *r) */ static int napi_rx_handler(struct net_device *dev, int *budget) { - struct adapter *adap = dev->priv; + const struct port_info *pi = netdev_priv(dev); + struct adapter *adap = pi->adapter; struct sge_qset *qs = dev2qset(dev); int effective_budget = min(*budget, dev->quota); @@ -2205,7 +2209,8 @@ static inline int handle_responses(struct adapter *adap, struct sge_rspq *q) irqreturn_t t3_sge_intr_msix(int irq, void *cookie) { struct sge_qset *qs = cookie; - struct adapter *adap = qs->netdev->priv; + const struct port_info *pi = netdev_priv(qs->netdev); + struct adapter *adap = pi->adapter; struct sge_rspq *q = &qs->rspq; spin_lock(&q->lock); @@ -2224,7 +2229,8 @@ irqreturn_t t3_sge_intr_msix(int irq, void *cookie) irqreturn_t t3_sge_intr_msix_napi(int irq, void *cookie) { struct sge_qset *qs = cookie; - struct adapter *adap = qs->netdev->priv; + const struct port_info *pi = netdev_priv(qs->netdev); + struct adapter *adap = pi->adapter; struct sge_rspq *q = &qs->rspq; spin_lock(&q->lock); @@ -2508,7 +2514,8 @@ static void sge_timer_cb(unsigned long data) { spinlock_t *lock; struct sge_qset *qs = (struct sge_qset *)data; - struct adapter *adap = qs->netdev->priv; + const struct port_info *pi = netdev_priv(qs->netdev); + struct adapter *adap = pi->adapter; if (spin_trylock(&qs->txq[TXQ_ETH].lock)) { reclaim_completed_tx(adap, &qs->txq[TXQ_ETH]); diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c index dd3149d94ba8..b02d15daf5d9 100644 --- a/drivers/net/cxgb3/t3_hw.c +++ b/drivers/net/cxgb3/t3_hw.c @@ -848,16 +848,15 @@ static int t3_write_flash(struct adapter *adapter, unsigned int addr, } /** - * t3_check_tpsram_version - read the tp sram version + * t3_get_tp_version - read the tp sram version * @adapter: the adapter + * @vers: where to place the version * - * Reads the protocol sram version from serial eeprom. + * Reads the protocol sram version from sram. */ -int t3_check_tpsram_version(struct adapter *adapter) +int t3_get_tp_version(struct adapter *adapter, u32 *vers) { int ret; - u32 vers; - unsigned int major, minor; /* Get version loaded in SRAM */ t3_write_reg(adapter, A_TP_EMBED_OP_FIELD0, 0); @@ -866,7 +865,32 @@ int t3_check_tpsram_version(struct adapter *adapter) if (ret) return ret; - vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1); + *vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1); + + return 0; +} + +/** + * t3_check_tpsram_version - read the tp sram version + * @adapter: the adapter + * @must_load: set to 1 if loading a new microcode image is required + * + * Reads the protocol sram version from flash. + */ +int t3_check_tpsram_version(struct adapter *adapter, int *must_load) +{ + int ret; + u32 vers; + unsigned int major, minor; + + if (adapter->params.rev == T3_REV_A) + return 0; + + *must_load = 1; + + ret = t3_get_tp_version(adapter, &vers); + if (ret) + return ret; major = G_TP_VERSION_MAJOR(vers); minor = G_TP_VERSION_MINOR(vers); @@ -874,6 +898,16 @@ int t3_check_tpsram_version(struct adapter *adapter) if (major == TP_VERSION_MAJOR && minor == TP_VERSION_MINOR) return 0; + if (major != TP_VERSION_MAJOR) + CH_ERR(adapter, "found wrong TP version (%u.%u), " + "driver needs version %d.%d\n", major, minor, + TP_VERSION_MAJOR, TP_VERSION_MINOR); + else { + *must_load = 0; + CH_ERR(adapter, "found wrong TP version (%u.%u), " + "driver compiled for version %d.%d\n", major, minor, + TP_VERSION_MAJOR, TP_VERSION_MINOR); + } return -EINVAL; } diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h index fa4099bc0416..77fcc1a4984e 100644 --- a/drivers/net/cxgb3/t3cdev.h +++ b/drivers/net/cxgb3/t3cdev.h @@ -42,9 +42,6 @@ #define T3CNAMSIZ 16 -/* Get the t3cdev associated with a net_device */ -#define T3CDEV(netdev) (struct t3cdev *)(netdev->priv) - struct cxgb3_client; enum t3ctype { |