aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2007-08-29 22:15:47 -0400
committerJeff Garzik <jeff@garzik.org>2007-08-31 07:29:08 -0400
commit5fbf816fe7d72bfdbf22bfec05b4ec3aa6849f72 (patch)
tree62f35df3e9078e3f981b9c04176d9a9cb557a53a
parent54d0f56e63edb1aa3901ea6389bf7ea5d43d0c22 (diff)
cxgb3 - Fix dev->priv usage
cxgb3 used netdev_priv() and dev->priv for different purposes. In 2.6.23, netdev_priv() == dev->priv, cxgb3 needs a fix. This patch is a partial backport of Dave Miller's changes in the net-2.6.24 git branch. Without this fix, cxgb3 crashes on 2.6.23. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c2
-rw-r--r--drivers/net/cxgb3/adapter.h2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c126
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c16
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.h2
-rw-r--r--drivers/net/cxgb3/sge.c23
-rw-r--r--drivers/net/cxgb3/t3cdev.h3
7 files changed, 105 insertions, 69 deletions
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index 1518b41482a..beb2a381467 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -916,7 +916,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
916 PDBG("%s opening rnic dev %s\n", __FUNCTION__, rdev_p->dev_name); 916 PDBG("%s opening rnic dev %s\n", __FUNCTION__, rdev_p->dev_name);
917 memset(&rdev_p->ctrl_qp, 0, sizeof(rdev_p->ctrl_qp)); 917 memset(&rdev_p->ctrl_qp, 0, sizeof(rdev_p->ctrl_qp));
918 if (!rdev_p->t3cdev_p) 918 if (!rdev_p->t3cdev_p)
919 rdev_p->t3cdev_p = T3CDEV(netdev_p); 919 rdev_p->t3cdev_p = dev2t3cdev(netdev_p);
920 rdev_p->t3cdev_p->ulp = (void *) rdev_p; 920 rdev_p->t3cdev_p->ulp = (void *) rdev_p;
921 err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_GET_PARAMS, 921 err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_GET_PARAMS,
922 &(rdev_p->rnic_info)); 922 &(rdev_p->rnic_info));
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index ab72563b81e..20e887de254 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 *);
50 50
51struct vlan_group; 51struct vlan_group;
52 52
53struct adapter;
53struct port_info { 54struct port_info {
55 struct adapter *adapter;
54 struct vlan_group *vlan_grp; 56 struct vlan_group *vlan_grp;
55 const struct port_type_info *port_type; 57 const struct port_type_info *port_type;
56 u8 port_id; 58 u8 port_id;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index dc5d26988bb..f3bf1283c9a 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)
358 358
359 for (j = 0; j < pi->nqsets - 1; j++) { 359 for (j = 0; j < pi->nqsets - 1; j++) {
360 if (!adap->dummy_netdev[dummy_idx]) { 360 if (!adap->dummy_netdev[dummy_idx]) {
361 nd = alloc_netdev(0, "", ether_setup); 361 struct port_info *p;
362
363 nd = alloc_netdev(sizeof(*p), "", ether_setup);
362 if (!nd) 364 if (!nd)
363 goto free_all; 365 goto free_all;
364 366
365 nd->priv = adap; 367 p = netdev_priv(nd);
368 p->adapter = adap;
366 nd->weight = 64; 369 nd->weight = 64;
367 set_bit(__LINK_STATE_START, &nd->state); 370 set_bit(__LINK_STATE_START, &nd->state);
368 adap->dummy_netdev[dummy_idx] = nd; 371 adap->dummy_netdev[dummy_idx] = nd;
@@ -482,7 +485,8 @@ static ssize_t attr_store(struct device *d, struct device_attribute *attr,
482#define CXGB3_SHOW(name, val_expr) \ 485#define CXGB3_SHOW(name, val_expr) \
483static ssize_t format_##name(struct net_device *dev, char *buf) \ 486static ssize_t format_##name(struct net_device *dev, char *buf) \
484{ \ 487{ \
485 struct adapter *adap = dev->priv; \ 488 struct port_info *pi = netdev_priv(dev); \
489 struct adapter *adap = pi->adapter; \
486 return sprintf(buf, "%u\n", val_expr); \ 490 return sprintf(buf, "%u\n", val_expr); \
487} \ 491} \
488static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ 492static 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, \
493 497
494static ssize_t set_nfilters(struct net_device *dev, unsigned int val) 498static ssize_t set_nfilters(struct net_device *dev, unsigned int val)
495{ 499{
496 struct adapter *adap = dev->priv; 500 struct port_info *pi = netdev_priv(dev);
501 struct adapter *adap = pi->adapter;
497 int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0; 502 int min_tids = is_offload(adap) ? MC5_MIN_TIDS : 0;
498 503
499 if (adap->flags & FULL_INIT_DONE) 504 if (adap->flags & FULL_INIT_DONE)
@@ -515,7 +520,8 @@ static ssize_t store_nfilters(struct device *d, struct device_attribute *attr,
515 520
516static ssize_t set_nservers(struct net_device *dev, unsigned int val) 521static ssize_t set_nservers(struct net_device *dev, unsigned int val)
517{ 522{
518 struct adapter *adap = dev->priv; 523 struct port_info *pi = netdev_priv(dev);
524 struct adapter *adap = pi->adapter;
519 525
520 if (adap->flags & FULL_INIT_DONE) 526 if (adap->flags & FULL_INIT_DONE)
521 return -EBUSY; 527 return -EBUSY;
@@ -556,9 +562,10 @@ static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs };
556static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, 562static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr,
557 char *buf, int sched) 563 char *buf, int sched)
558{ 564{
559 ssize_t len; 565 struct port_info *pi = netdev_priv(to_net_dev(d));
566 struct adapter *adap = pi->adapter;
560 unsigned int v, addr, bpt, cpt; 567 unsigned int v, addr, bpt, cpt;
561 struct adapter *adap = to_net_dev(d)->priv; 568 ssize_t len;
562 569
563 addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; 570 addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2;
564 rtnl_lock(); 571 rtnl_lock();
@@ -581,10 +588,11 @@ static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr,
581static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, 588static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr,
582 const char *buf, size_t len, int sched) 589 const char *buf, size_t len, int sched)
583{ 590{
591 struct port_info *pi = netdev_priv(to_net_dev(d));
592 struct adapter *adap = pi->adapter;
593 unsigned int val;
584 char *endp; 594 char *endp;
585 ssize_t ret; 595 ssize_t ret;
586 unsigned int val;
587 struct adapter *adap = to_net_dev(d)->priv;
588 596
589 if (!capable(CAP_NET_ADMIN)) 597 if (!capable(CAP_NET_ADMIN))
590 return -EPERM; 598 return -EPERM;
@@ -858,8 +866,9 @@ static void schedule_chk_task(struct adapter *adap)
858 866
859static int offload_open(struct net_device *dev) 867static int offload_open(struct net_device *dev)
860{ 868{
861 struct adapter *adapter = dev->priv; 869 struct port_info *pi = netdev_priv(dev);
862 struct t3cdev *tdev = T3CDEV(dev); 870 struct adapter *adapter = pi->adapter;
871 struct t3cdev *tdev = dev2t3cdev(dev);
863 int adap_up = adapter->open_device_map & PORT_MASK; 872 int adap_up = adapter->open_device_map & PORT_MASK;
864 int err = 0; 873 int err = 0;
865 874
@@ -924,10 +933,10 @@ static int offload_close(struct t3cdev *tdev)
924 933
925static int cxgb_open(struct net_device *dev) 934static int cxgb_open(struct net_device *dev)
926{ 935{
927 int err;
928 struct adapter *adapter = dev->priv;
929 struct port_info *pi = netdev_priv(dev); 936 struct port_info *pi = netdev_priv(dev);
937 struct adapter *adapter = pi->adapter;
930 int other_ports = adapter->open_device_map & PORT_MASK; 938 int other_ports = adapter->open_device_map & PORT_MASK;
939 int err;
931 940
932 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) 941 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0)
933 return err; 942 return err;
@@ -951,17 +960,17 @@ static int cxgb_open(struct net_device *dev)
951 960
952static int cxgb_close(struct net_device *dev) 961static int cxgb_close(struct net_device *dev)
953{ 962{
954 struct adapter *adapter = dev->priv; 963 struct port_info *pi = netdev_priv(dev);
955 struct port_info *p = netdev_priv(dev); 964 struct adapter *adapter = pi->adapter;
956 965
957 t3_port_intr_disable(adapter, p->port_id); 966 t3_port_intr_disable(adapter, pi->port_id);
958 netif_stop_queue(dev); 967 netif_stop_queue(dev);
959 p->phy.ops->power_down(&p->phy, 1); 968 pi->phy.ops->power_down(&pi->phy, 1);
960 netif_carrier_off(dev); 969 netif_carrier_off(dev);
961 t3_mac_disable(&p->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX); 970 t3_mac_disable(&pi->mac, MAC_DIRECTION_TX | MAC_DIRECTION_RX);
962 971
963 spin_lock(&adapter->work_lock); /* sync with update task */ 972 spin_lock(&adapter->work_lock); /* sync with update task */
964 clear_bit(p->port_id, &adapter->open_device_map); 973 clear_bit(pi->port_id, &adapter->open_device_map);
965 spin_unlock(&adapter->work_lock); 974 spin_unlock(&adapter->work_lock);
966 975
967 if (!(adapter->open_device_map & PORT_MASK)) 976 if (!(adapter->open_device_map & PORT_MASK))
@@ -976,13 +985,13 @@ static int cxgb_close(struct net_device *dev)
976 985
977static struct net_device_stats *cxgb_get_stats(struct net_device *dev) 986static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
978{ 987{
979 struct adapter *adapter = dev->priv; 988 struct port_info *pi = netdev_priv(dev);
980 struct port_info *p = netdev_priv(dev); 989 struct adapter *adapter = pi->adapter;
981 struct net_device_stats *ns = &p->netstats; 990 struct net_device_stats *ns = &pi->netstats;
982 const struct mac_stats *pstats; 991 const struct mac_stats *pstats;
983 992
984 spin_lock(&adapter->stats_lock); 993 spin_lock(&adapter->stats_lock);
985 pstats = t3_mac_update_stats(&p->mac); 994 pstats = t3_mac_update_stats(&pi->mac);
986 spin_unlock(&adapter->stats_lock); 995 spin_unlock(&adapter->stats_lock);
987 996
988 ns->tx_bytes = pstats->tx_octets; 997 ns->tx_bytes = pstats->tx_octets;
@@ -1015,14 +1024,16 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
1015 1024
1016static u32 get_msglevel(struct net_device *dev) 1025static u32 get_msglevel(struct net_device *dev)
1017{ 1026{
1018 struct adapter *adapter = dev->priv; 1027 struct port_info *pi = netdev_priv(dev);
1028 struct adapter *adapter = pi->adapter;
1019 1029
1020 return adapter->msg_enable; 1030 return adapter->msg_enable;
1021} 1031}
1022 1032
1023static void set_msglevel(struct net_device *dev, u32 val) 1033static void set_msglevel(struct net_device *dev, u32 val)
1024{ 1034{
1025 struct adapter *adapter = dev->priv; 1035 struct port_info *pi = netdev_priv(dev);
1036 struct adapter *adapter = pi->adapter;
1026 1037
1027 adapter->msg_enable = val; 1038 adapter->msg_enable = val;
1028} 1039}
@@ -1096,8 +1107,9 @@ static int get_eeprom_len(struct net_device *dev)
1096 1107
1097static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1108static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1098{ 1109{
1110 struct port_info *pi = netdev_priv(dev);
1111 struct adapter *adapter = pi->adapter;
1099 u32 fw_vers = 0; 1112 u32 fw_vers = 0;
1100 struct adapter *adapter = dev->priv;
1101 1113
1102 t3_get_fw_version(adapter, &fw_vers); 1114 t3_get_fw_version(adapter, &fw_vers);
1103 1115
@@ -1136,8 +1148,8 @@ static unsigned long collect_sge_port_stats(struct adapter *adapter,
1136static void get_stats(struct net_device *dev, struct ethtool_stats *stats, 1148static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
1137 u64 *data) 1149 u64 *data)
1138{ 1150{
1139 struct adapter *adapter = dev->priv;
1140 struct port_info *pi = netdev_priv(dev); 1151 struct port_info *pi = netdev_priv(dev);
1152 struct adapter *adapter = pi->adapter;
1141 const struct mac_stats *s; 1153 const struct mac_stats *s;
1142 1154
1143 spin_lock(&adapter->stats_lock); 1155 spin_lock(&adapter->stats_lock);
@@ -1205,7 +1217,8 @@ static inline void reg_block_dump(struct adapter *ap, void *buf,
1205static void get_regs(struct net_device *dev, struct ethtool_regs *regs, 1217static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
1206 void *buf) 1218 void *buf)
1207{ 1219{
1208 struct adapter *ap = dev->priv; 1220 struct port_info *pi = netdev_priv(dev);
1221 struct adapter *ap = pi->adapter;
1209 1222
1210 /* 1223 /*
1211 * Version scheme: 1224 * Version scheme:
@@ -1246,8 +1259,9 @@ static int restart_autoneg(struct net_device *dev)
1246 1259
1247static int cxgb3_phys_id(struct net_device *dev, u32 data) 1260static int cxgb3_phys_id(struct net_device *dev, u32 data)
1248{ 1261{
1262 struct port_info *pi = netdev_priv(dev);
1263 struct adapter *adapter = pi->adapter;
1249 int i; 1264 int i;
1250 struct adapter *adapter = dev->priv;
1251 1265
1252 if (data == 0) 1266 if (data == 0)
1253 data = 2; 1267 data = 2;
@@ -1408,8 +1422,8 @@ static int set_rx_csum(struct net_device *dev, u32 data)
1408 1422
1409static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e) 1423static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1410{ 1424{
1411 const struct adapter *adapter = dev->priv; 1425 struct port_info *pi = netdev_priv(dev);
1412 const struct port_info *pi = netdev_priv(dev); 1426 struct adapter *adapter = pi->adapter;
1413 const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset]; 1427 const struct qset_params *q = &adapter->params.sge.qset[pi->first_qset];
1414 1428
1415 e->rx_max_pending = MAX_RX_BUFFERS; 1429 e->rx_max_pending = MAX_RX_BUFFERS;
@@ -1425,10 +1439,10 @@ static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1425 1439
1426static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e) 1440static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1427{ 1441{
1428 int i; 1442 struct port_info *pi = netdev_priv(dev);
1443 struct adapter *adapter = pi->adapter;
1429 struct qset_params *q; 1444 struct qset_params *q;
1430 struct adapter *adapter = dev->priv; 1445 int i;
1431 const struct port_info *pi = netdev_priv(dev);
1432 1446
1433 if (e->rx_pending > MAX_RX_BUFFERS || 1447 if (e->rx_pending > MAX_RX_BUFFERS ||
1434 e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS || 1448 e->rx_jumbo_pending > MAX_RX_JUMBO_BUFFERS ||
@@ -1457,7 +1471,8 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1457 1471
1458static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 1472static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1459{ 1473{
1460 struct adapter *adapter = dev->priv; 1474 struct port_info *pi = netdev_priv(dev);
1475 struct adapter *adapter = pi->adapter;
1461 struct qset_params *qsp = &adapter->params.sge.qset[0]; 1476 struct qset_params *qsp = &adapter->params.sge.qset[0];
1462 struct sge_qset *qs = &adapter->sge.qs[0]; 1477 struct sge_qset *qs = &adapter->sge.qs[0];
1463 1478
@@ -1471,7 +1486,8 @@ static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1471 1486
1472static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c) 1487static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1473{ 1488{
1474 struct adapter *adapter = dev->priv; 1489 struct port_info *pi = netdev_priv(dev);
1490 struct adapter *adapter = pi->adapter;
1475 struct qset_params *q = adapter->params.sge.qset; 1491 struct qset_params *q = adapter->params.sge.qset;
1476 1492
1477 c->rx_coalesce_usecs = q->coalesce_usecs; 1493 c->rx_coalesce_usecs = q->coalesce_usecs;
@@ -1481,8 +1497,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1481static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e, 1497static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
1482 u8 * data) 1498 u8 * data)
1483{ 1499{
1500 struct port_info *pi = netdev_priv(dev);
1501 struct adapter *adapter = pi->adapter;
1484 int i, err = 0; 1502 int i, err = 0;
1485 struct adapter *adapter = dev->priv;
1486 1503
1487 u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL); 1504 u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
1488 if (!buf) 1505 if (!buf)
@@ -1501,10 +1518,11 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
1501static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 1518static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
1502 u8 * data) 1519 u8 * data)
1503{ 1520{
1521 struct port_info *pi = netdev_priv(dev);
1522 struct adapter *adapter = pi->adapter;
1523 u32 aligned_offset, aligned_len, *p;
1504 u8 *buf; 1524 u8 *buf;
1505 int err = 0; 1525 int err = 0;
1506 u32 aligned_offset, aligned_len, *p;
1507 struct adapter *adapter = dev->priv;
1508 1526
1509 if (eeprom->magic != EEPROM_MAGIC) 1527 if (eeprom->magic != EEPROM_MAGIC)
1510 return -EINVAL; 1528 return -EINVAL;
@@ -1592,9 +1610,10 @@ static int in_range(int val, int lo, int hi)
1592 1610
1593static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) 1611static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1594{ 1612{
1595 int ret; 1613 struct port_info *pi = netdev_priv(dev);
1614 struct adapter *adapter = pi->adapter;
1596 u32 cmd; 1615 u32 cmd;
1597 struct adapter *adapter = dev->priv; 1616 int ret;
1598 1617
1599 if (copy_from_user(&cmd, useraddr, sizeof(cmd))) 1618 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
1600 return -EFAULT; 1619 return -EFAULT;
@@ -1923,10 +1942,10 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1923 1942
1924static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 1943static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1925{ 1944{
1926 int ret, mmd;
1927 struct adapter *adapter = dev->priv;
1928 struct port_info *pi = netdev_priv(dev);
1929 struct mii_ioctl_data *data = if_mii(req); 1945 struct mii_ioctl_data *data = if_mii(req);
1946 struct port_info *pi = netdev_priv(dev);
1947 struct adapter *adapter = pi->adapter;
1948 int ret, mmd;
1930 1949
1931 switch (cmd) { 1950 switch (cmd) {
1932 case SIOCGMIIPHY: 1951 case SIOCGMIIPHY:
@@ -1994,9 +2013,9 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1994 2013
1995static int cxgb_change_mtu(struct net_device *dev, int new_mtu) 2014static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
1996{ 2015{
1997 int ret;
1998 struct adapter *adapter = dev->priv;
1999 struct port_info *pi = netdev_priv(dev); 2016 struct port_info *pi = netdev_priv(dev);
2017 struct adapter *adapter = pi->adapter;
2018 int ret;
2000 2019
2001 if (new_mtu < 81) /* accommodate SACK */ 2020 if (new_mtu < 81) /* accommodate SACK */
2002 return -EINVAL; 2021 return -EINVAL;
@@ -2013,8 +2032,8 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
2013 2032
2014static int cxgb_set_mac_addr(struct net_device *dev, void *p) 2033static int cxgb_set_mac_addr(struct net_device *dev, void *p)
2015{ 2034{
2016 struct adapter *adapter = dev->priv;
2017 struct port_info *pi = netdev_priv(dev); 2035 struct port_info *pi = netdev_priv(dev);
2036 struct adapter *adapter = pi->adapter;
2018 struct sockaddr *addr = p; 2037 struct sockaddr *addr = p;
2019 2038
2020 if (!is_valid_ether_addr(addr->sa_data)) 2039 if (!is_valid_ether_addr(addr->sa_data))
@@ -2050,8 +2069,8 @@ static void t3_synchronize_rx(struct adapter *adap, const struct port_info *p)
2050 2069
2051static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp) 2070static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
2052{ 2071{
2053 struct adapter *adapter = dev->priv;
2054 struct port_info *pi = netdev_priv(dev); 2072 struct port_info *pi = netdev_priv(dev);
2073 struct adapter *adapter = pi->adapter;
2055 2074
2056 pi->vlan_grp = grp; 2075 pi->vlan_grp = grp;
2057 if (adapter->params.rev > 0) 2076 if (adapter->params.rev > 0)
@@ -2070,8 +2089,8 @@ static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
2070#ifdef CONFIG_NET_POLL_CONTROLLER 2089#ifdef CONFIG_NET_POLL_CONTROLLER
2071static void cxgb_netpoll(struct net_device *dev) 2090static void cxgb_netpoll(struct net_device *dev)
2072{ 2091{
2073 struct adapter *adapter = dev->priv;
2074 struct port_info *pi = netdev_priv(dev); 2092 struct port_info *pi = netdev_priv(dev);
2093 struct adapter *adapter = pi->adapter;
2075 int qidx; 2094 int qidx;
2076 2095
2077 for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) { 2096 for (qidx = pi->first_qset; qidx < pi->first_qset + pi->nqsets; qidx++) {
@@ -2433,6 +2452,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2433 2452
2434 adapter->port[i] = netdev; 2453 adapter->port[i] = netdev;
2435 pi = netdev_priv(netdev); 2454 pi = netdev_priv(netdev);
2455 pi->adapter = adapter;
2436 pi->rx_csum_offload = 1; 2456 pi->rx_csum_offload = 1;
2437 pi->nqsets = 1; 2457 pi->nqsets = 1;
2438 pi->first_qset = i; 2458 pi->first_qset = i;
@@ -2442,7 +2462,6 @@ static int __devinit init_one(struct pci_dev *pdev,
2442 netdev->irq = pdev->irq; 2462 netdev->irq = pdev->irq;
2443 netdev->mem_start = mmio_start; 2463 netdev->mem_start = mmio_start;
2444 netdev->mem_end = mmio_start + mmio_len - 1; 2464 netdev->mem_end = mmio_start + mmio_len - 1;
2445 netdev->priv = adapter;
2446 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 2465 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
2447 netdev->features |= NETIF_F_LLTX; 2466 netdev->features |= NETIF_F_LLTX;
2448 if (pci_using_dac) 2467 if (pci_using_dac)
@@ -2467,7 +2486,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2467 SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops); 2486 SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops);
2468 } 2487 }
2469 2488
2470 pci_set_drvdata(pdev, adapter->port[0]); 2489 pci_set_drvdata(pdev, adapter);
2471 if (t3_prep_adapter(adapter, ai, 1) < 0) { 2490 if (t3_prep_adapter(adapter, ai, 1) < 0) {
2472 err = -ENODEV; 2491 err = -ENODEV;
2473 goto out_free_dev; 2492 goto out_free_dev;
@@ -2547,11 +2566,10 @@ out_release_regions:
2547 2566
2548static void __devexit remove_one(struct pci_dev *pdev) 2567static void __devexit remove_one(struct pci_dev *pdev)
2549{ 2568{
2550 struct net_device *dev = pci_get_drvdata(pdev); 2569 struct adapter *adapter = pci_get_drvdata(pdev);
2551 2570
2552 if (dev) { 2571 if (adapter) {
2553 int i; 2572 int i;
2554 struct adapter *adapter = dev->priv;
2555 2573
2556 t3_sge_stop(adapter); 2574 t3_sge_stop(adapter);
2557 sysfs_remove_group(&adapter->port[0]->dev.kobj, 2575 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 e620ed4c3ff..bdff7baeb59 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,
593 593
594EXPORT_SYMBOL(cxgb3_alloc_stid); 594EXPORT_SYMBOL(cxgb3_alloc_stid);
595 595
596/* Get the t3cdev associated with a net_device */
597struct t3cdev *dev2t3cdev(struct net_device *dev)
598{
599 const struct port_info *pi = netdev_priv(dev);
600
601 return (struct t3cdev *)pi->adapter;
602}
603
604EXPORT_SYMBOL(dev2t3cdev);
605
596static int do_smt_write_rpl(struct t3cdev *dev, struct sk_buff *skb) 606static int do_smt_write_rpl(struct t3cdev *dev, struct sk_buff *skb)
597{ 607{
598 struct cpl_smt_write_rpl *rpl = cplhdr(skb); 608 struct cpl_smt_write_rpl *rpl = cplhdr(skb);
@@ -925,7 +935,7 @@ void cxgb_neigh_update(struct neighbour *neigh)
925 struct net_device *dev = neigh->dev; 935 struct net_device *dev = neigh->dev;
926 936
927 if (dev && (is_offloading(dev))) { 937 if (dev && (is_offloading(dev))) {
928 struct t3cdev *tdev = T3CDEV(dev); 938 struct t3cdev *tdev = dev2t3cdev(dev);
929 939
930 BUG_ON(!tdev); 940 BUG_ON(!tdev);
931 t3_l2t_update(tdev, neigh); 941 t3_l2t_update(tdev, neigh);
@@ -973,9 +983,9 @@ void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
973 "device ignored.\n", __FUNCTION__); 983 "device ignored.\n", __FUNCTION__);
974 return; 984 return;
975 } 985 }
976 tdev = T3CDEV(olddev); 986 tdev = dev2t3cdev(olddev);
977 BUG_ON(!tdev); 987 BUG_ON(!tdev);
978 if (tdev != T3CDEV(newdev)) { 988 if (tdev != dev2t3cdev(newdev)) {
979 printk(KERN_WARNING "%s: Redirect to different " 989 printk(KERN_WARNING "%s: Redirect to different "
980 "offload device ignored.\n", __FUNCTION__); 990 "offload device ignored.\n", __FUNCTION__);
981 return; 991 return;
diff --git a/drivers/net/cxgb3/cxgb3_offload.h b/drivers/net/cxgb3/cxgb3_offload.h
index f15446a32ef..7a379138b5a 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);
51 51
52void cxgb3_set_dummy_ops(struct t3cdev *dev); 52void cxgb3_set_dummy_ops(struct t3cdev *dev);
53 53
54struct t3cdev *dev2t3cdev(struct net_device *dev);
55
54/* 56/*
55 * Client registration. Users of T3 driver must register themselves. 57 * Client registration. Users of T3 driver must register themselves.
56 * The T3 driver will call the add function of every client for each T3 58 * 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 a2cfd68ac75..58a5f60521e 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)
1073{ 1073{
1074 unsigned int ndesc, pidx, credits, gen, compl; 1074 unsigned int ndesc, pidx, credits, gen, compl;
1075 const struct port_info *pi = netdev_priv(dev); 1075 const struct port_info *pi = netdev_priv(dev);
1076 struct adapter *adap = dev->priv; 1076 struct adapter *adap = pi->adapter;
1077 struct sge_qset *qs = dev2qset(dev); 1077 struct sge_qset *qs = dev2qset(dev);
1078 struct sge_txq *q = &qs->txq[TXQ_ETH]; 1078 struct sge_txq *q = &qs->txq[TXQ_ETH];
1079 1079
@@ -1326,7 +1326,8 @@ static void restart_ctrlq(unsigned long data)
1326 struct sk_buff *skb; 1326 struct sk_buff *skb;
1327 struct sge_qset *qs = (struct sge_qset *)data; 1327 struct sge_qset *qs = (struct sge_qset *)data;
1328 struct sge_txq *q = &qs->txq[TXQ_CTRL]; 1328 struct sge_txq *q = &qs->txq[TXQ_CTRL];
1329 struct adapter *adap = qs->netdev->priv; 1329 const struct port_info *pi = netdev_priv(qs->netdev);
1330 struct adapter *adap = pi->adapter;
1330 1331
1331 spin_lock(&q->lock); 1332 spin_lock(&q->lock);
1332 again:reclaim_completed_tx_imm(q); 1333 again:reclaim_completed_tx_imm(q);
@@ -1531,7 +1532,8 @@ static void restart_offloadq(unsigned long data)
1531 struct sk_buff *skb; 1532 struct sk_buff *skb;
1532 struct sge_qset *qs = (struct sge_qset *)data; 1533 struct sge_qset *qs = (struct sge_qset *)data;
1533 struct sge_txq *q = &qs->txq[TXQ_OFLD]; 1534 struct sge_txq *q = &qs->txq[TXQ_OFLD];
1534 struct adapter *adap = qs->netdev->priv; 1535 const struct port_info *pi = netdev_priv(qs->netdev);
1536 struct adapter *adap = pi->adapter;
1535 1537
1536 spin_lock(&q->lock); 1538 spin_lock(&q->lock);
1537 again:reclaim_completed_tx(adap, q); 1539 again:reclaim_completed_tx(adap, q);
@@ -1675,7 +1677,8 @@ static inline void deliver_partial_bundle(struct t3cdev *tdev,
1675 */ 1677 */
1676static int ofld_poll(struct net_device *dev, int *budget) 1678static int ofld_poll(struct net_device *dev, int *budget)
1677{ 1679{
1678 struct adapter *adapter = dev->priv; 1680 const struct port_info *pi = netdev_priv(dev);
1681 struct adapter *adapter = pi->adapter;
1679 struct sge_qset *qs = dev2qset(dev); 1682 struct sge_qset *qs = dev2qset(dev);
1680 struct sge_rspq *q = &qs->rspq; 1683 struct sge_rspq *q = &qs->rspq;
1681 int work_done, limit = min(*budget, dev->quota), avail = limit; 1684 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)
2075 */ 2078 */
2076static int napi_rx_handler(struct net_device *dev, int *budget) 2079static int napi_rx_handler(struct net_device *dev, int *budget)
2077{ 2080{
2078 struct adapter *adap = dev->priv; 2081 const struct port_info *pi = netdev_priv(dev);
2082 struct adapter *adap = pi->adapter;
2079 struct sge_qset *qs = dev2qset(dev); 2083 struct sge_qset *qs = dev2qset(dev);
2080 int effective_budget = min(*budget, dev->quota); 2084 int effective_budget = min(*budget, dev->quota);
2081 2085
@@ -2205,7 +2209,8 @@ static inline int handle_responses(struct adapter *adap, struct sge_rspq *q)
2205irqreturn_t t3_sge_intr_msix(int irq, void *cookie) 2209irqreturn_t t3_sge_intr_msix(int irq, void *cookie)
2206{ 2210{
2207 struct sge_qset *qs = cookie; 2211 struct sge_qset *qs = cookie;
2208 struct adapter *adap = qs->netdev->priv; 2212 const struct port_info *pi = netdev_priv(qs->netdev);
2213 struct adapter *adap = pi->adapter;
2209 struct sge_rspq *q = &qs->rspq; 2214 struct sge_rspq *q = &qs->rspq;
2210 2215
2211 spin_lock(&q->lock); 2216 spin_lock(&q->lock);
@@ -2224,7 +2229,8 @@ irqreturn_t t3_sge_intr_msix(int irq, void *cookie)
2224irqreturn_t t3_sge_intr_msix_napi(int irq, void *cookie) 2229irqreturn_t t3_sge_intr_msix_napi(int irq, void *cookie)
2225{ 2230{
2226 struct sge_qset *qs = cookie; 2231 struct sge_qset *qs = cookie;
2227 struct adapter *adap = qs->netdev->priv; 2232 const struct port_info *pi = netdev_priv(qs->netdev);
2233 struct adapter *adap = pi->adapter;
2228 struct sge_rspq *q = &qs->rspq; 2234 struct sge_rspq *q = &qs->rspq;
2229 2235
2230 spin_lock(&q->lock); 2236 spin_lock(&q->lock);
@@ -2508,7 +2514,8 @@ static void sge_timer_cb(unsigned long data)
2508{ 2514{
2509 spinlock_t *lock; 2515 spinlock_t *lock;
2510 struct sge_qset *qs = (struct sge_qset *)data; 2516 struct sge_qset *qs = (struct sge_qset *)data;
2511 struct adapter *adap = qs->netdev->priv; 2517 const struct port_info *pi = netdev_priv(qs->netdev);
2518 struct adapter *adap = pi->adapter;
2512 2519
2513 if (spin_trylock(&qs->txq[TXQ_ETH].lock)) { 2520 if (spin_trylock(&qs->txq[TXQ_ETH].lock)) {
2514 reclaim_completed_tx(adap, &qs->txq[TXQ_ETH]); 2521 reclaim_completed_tx(adap, &qs->txq[TXQ_ETH]);
diff --git a/drivers/net/cxgb3/t3cdev.h b/drivers/net/cxgb3/t3cdev.h
index fa4099bc041..77fcc1a4984 100644
--- a/drivers/net/cxgb3/t3cdev.h
+++ b/drivers/net/cxgb3/t3cdev.h
@@ -42,9 +42,6 @@
42 42
43#define T3CNAMSIZ 16 43#define T3CNAMSIZ 16
44 44
45/* Get the t3cdev associated with a net_device */
46#define T3CDEV(netdev) (struct t3cdev *)(netdev->priv)
47
48struct cxgb3_client; 45struct cxgb3_client;
49 46
50enum t3ctype { 47enum t3ctype {