Skip to contentSkip to conversation

cxgb3 - Fix dev->priv usage

PATCH RESEND Applied Divy Le Ray 3 participants 5 messages Aug 23, 2007 – Aug 28, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 cxgb3 - Fix dev->priv usage

From: Divy Le Ray <[email protected]>

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.

---

 drivers/net/cxgb3/adapter.h       |   10 +++
 drivers/net/cxgb3/cxgb3_main.c    |  126 +++++++++++++++++++++----------------
 drivers/net/cxgb3/cxgb3_offload.c |    6 +-
 drivers/net/cxgb3/sge.c           |   23 ++++---
 drivers/net/cxgb3/t3cdev.h        |    3 -
 5 files changed, 100 insertions(+), 68 deletions(-)
drivers/net/cxgb3/adapter.h +10 -0
index ab72563..c1dc344 100644
@@ -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;
@@ -246,6 +248,14 @@ static inline void t3_write_reg(struct adapter *adapter, u32 reg_addr, u32 val)
 	writel(val, adapter->regs + reg_addr);
 }
 
+/* Get the t3cdev associated with a net_device */
+static inline struct t3cdev *dev2t3cdev(struct net_device *dev)
+{
+	const struct port_info *pi = netdev_priv(dev);
+
+	return (struct t3cdev *)pi->adapter;
+}
+
 static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
 {
 	return netdev_priv(adap->port[idx]);
drivers/net/cxgb3/cxgb3_main.c +72 -54

349 lines not on this page · raw message

drivers/net/cxgb3/cxgb3_offload.c +3 -3
index e620ed4..83d3555 100644
@@ -925,7 +925,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 +973,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;
drivers/net/cxgb3/sge.c +15 -8
index a2cfd68..58a5f60 100644
@@ -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]);
drivers/net/cxgb3/t3cdev.h +0 -3
index fa4099b..77fcc1a 100644
@@ -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 {
Applied
#1 lore raw
Quoted 9 lines · Divy Le Ray

From: Divy Le Ray <[email protected]>

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.

Quoted 9 lines

---

 drivers/net/cxgb3/adapter.h       |   10 +++
 drivers/net/cxgb3/cxgb3_main.c    |  126 +++++++++++++++++++++----------------
 drivers/net/cxgb3/cxgb3_offload.c |    6 +-
 drivers/net/cxgb3/sge.c           |   23 ++++---
 drivers/net/cxgb3/t3cdev.h        |    3 -
 5 files changed, 100 insertions(+), 68 deletions(-)

applied

#2 lore raw
Quoted 20 lines · Jeff Garzik
Quoted 10 lines · Divy Le Ray

From: Divy Le Ray <[email protected]>

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.

---

Quoted 8 lines
 drivers/net/cxgb3/adapter.h       |   10 +++
 drivers/net/cxgb3/cxgb3_main.c    |  126 
+++++++++++++++++++++----------------
 drivers/net/cxgb3/cxgb3_offload.c |    6 +-
 drivers/net/cxgb3/sge.c           |   23 ++++---
 drivers/net/cxgb3/t3cdev.h        |    3 -
 5 files changed, 100 insertions(+), 68 deletions(-)
Quoted 1 line

applied

I take that back. Rejected -- it breaks infiniband build.

#3 lore raw
Quoted 1 line

I take that back. Rejected -- it breaks infiniband build.

To be more precise:

drivers/infiniband/hw/cxgb3/cxio_hal.c: In function 'cxio_rdev_open':
drivers/infiniband/hw/cxgb3/cxio_hal.c:919: error: implicit declaration of function 'T3CDEV'

it seems the problem is that T3CDEV() has been deleted and been replaced with the dev2t3cdev() inline function. However a simple replacement s/T3CDEV/dev2t3cdev/ in drivers/infiniband/hw/cxgb3 doesn't work because the function has moved from t3cdev.h to adapter.h; and moving the function back to t3cdev.h doesn't work because it depends on more structure definitions now.

And at that point I gave up...

- R.

#4 lore raw
Quoted 7 lines · Roland Dreier
Quoted 1 line

I take that back. Rejected -- it breaks infiniband build.

To be more precise:

drivers/infiniband/hw/cxgb3/cxio_hal.c: In function 'cxio_rdev_open':
drivers/infiniband/hw/cxgb3/cxio_hal.c:919: error: implicit declaration of function 'T3CDEV'

Quoted 9 lines

it seems the problem is that T3CDEV() has been deleted and been replaced with the dev2t3cdev() inline function. However a simple replacement s/T3CDEV/dev2t3cdev/ in drivers/infiniband/hw/cxgb3 doesn't work because the function has moved from t3cdev.h to adapter.h; and moving the function back to t3cdev.h doesn't work because it depends on more structure definitions now.

And at that point I gave up...

Sorry about the compilation issue and the delay to reply.
I'll post a follow up for the iw_cxgb3 driver later this evening.
I plan to move the inlined dev2t3cdev() from adapter.h to an exported dev2t3cdev() in cxgb3_offload.c.

Divy