Commit 5fbf816f authored by Divy Le Ray's avatar Divy Le Ray Committed by Jeff Garzik

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: default avatarDivy Le Ray <divy@chelsio.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 54d0f56e
...@@ -916,7 +916,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p) ...@@ -916,7 +916,7 @@ int cxio_rdev_open(struct cxio_rdev *rdev_p)
PDBG("%s opening rnic dev %s\n", __FUNCTION__, rdev_p->dev_name); PDBG("%s opening rnic dev %s\n", __FUNCTION__, rdev_p->dev_name);
memset(&rdev_p->ctrl_qp, 0, sizeof(rdev_p->ctrl_qp)); memset(&rdev_p->ctrl_qp, 0, sizeof(rdev_p->ctrl_qp));
if (!rdev_p->t3cdev_p) if (!rdev_p->t3cdev_p)
rdev_p->t3cdev_p = T3CDEV(netdev_p); rdev_p->t3cdev_p = dev2t3cdev(netdev_p);
rdev_p->t3cdev_p->ulp = (void *) rdev_p; rdev_p->t3cdev_p->ulp = (void *) rdev_p;
err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_GET_PARAMS, err = rdev_p->t3cdev_p->ctl(rdev_p->t3cdev_p, RDMA_GET_PARAMS,
&(rdev_p->rnic_info)); &(rdev_p->rnic_info));
......
...@@ -50,7 +50,9 @@ typedef irqreturn_t(*intr_handler_t) (int, void *); ...@@ -50,7 +50,9 @@ typedef irqreturn_t(*intr_handler_t) (int, void *);
struct vlan_group; struct vlan_group;
struct adapter;
struct port_info { struct port_info {
struct adapter *adapter;
struct vlan_group *vlan_grp; struct vlan_group *vlan_grp;
const struct port_type_info *port_type; const struct port_type_info *port_type;
u8 port_id; u8 port_id;
......
This diff is collapsed.
...@@ -593,6 +593,16 @@ int cxgb3_alloc_stid(struct t3cdev *tdev, struct cxgb3_client *client, ...@@ -593,6 +593,16 @@ int cxgb3_alloc_stid(struct t3cdev *tdev, struct cxgb3_client *client,
EXPORT_SYMBOL(cxgb3_alloc_stid); 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) static int do_smt_write_rpl(struct t3cdev *dev, struct sk_buff *skb)
{ {
struct cpl_smt_write_rpl *rpl = cplhdr(skb); struct cpl_smt_write_rpl *rpl = cplhdr(skb);
...@@ -925,7 +935,7 @@ void cxgb_neigh_update(struct neighbour *neigh) ...@@ -925,7 +935,7 @@ void cxgb_neigh_update(struct neighbour *neigh)
struct net_device *dev = neigh->dev; struct net_device *dev = neigh->dev;
if (dev && (is_offloading(dev))) { if (dev && (is_offloading(dev))) {
struct t3cdev *tdev = T3CDEV(dev); struct t3cdev *tdev = dev2t3cdev(dev);
BUG_ON(!tdev); BUG_ON(!tdev);
t3_l2t_update(tdev, neigh); t3_l2t_update(tdev, neigh);
...@@ -973,9 +983,9 @@ void cxgb_redirect(struct dst_entry *old, struct dst_entry *new) ...@@ -973,9 +983,9 @@ void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
"device ignored.\n", __FUNCTION__); "device ignored.\n", __FUNCTION__);
return; return;
} }
tdev = T3CDEV(olddev); tdev = dev2t3cdev(olddev);
BUG_ON(!tdev); BUG_ON(!tdev);
if (tdev != T3CDEV(newdev)) { if (tdev != dev2t3cdev(newdev)) {
printk(KERN_WARNING "%s: Redirect to different " printk(KERN_WARNING "%s: Redirect to different "
"offload device ignored.\n", __FUNCTION__); "offload device ignored.\n", __FUNCTION__);
return; return;
......
...@@ -51,6 +51,8 @@ void cxgb3_offload_deactivate(struct adapter *adapter); ...@@ -51,6 +51,8 @@ void cxgb3_offload_deactivate(struct adapter *adapter);
void cxgb3_set_dummy_ops(struct t3cdev *dev); void cxgb3_set_dummy_ops(struct t3cdev *dev);
struct t3cdev *dev2t3cdev(struct net_device *dev);
/* /*
* Client registration. Users of T3 driver must register themselves. * Client registration. Users of T3 driver must register themselves.
* The T3 driver will call the add function of every client for each T3 * The T3 driver will call the add function of every client for each T3
......
...@@ -1073,7 +1073,7 @@ int t3_eth_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1073,7 +1073,7 @@ int t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
unsigned int ndesc, pidx, credits, gen, compl; unsigned int ndesc, pidx, credits, gen, compl;
const struct port_info *pi = netdev_priv(dev); 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_qset *qs = dev2qset(dev);
struct sge_txq *q = &qs->txq[TXQ_ETH]; struct sge_txq *q = &qs->txq[TXQ_ETH];
...@@ -1326,7 +1326,8 @@ static void restart_ctrlq(unsigned long data) ...@@ -1326,7 +1326,8 @@ static void restart_ctrlq(unsigned long data)
struct sk_buff *skb; struct sk_buff *skb;
struct sge_qset *qs = (struct sge_qset *)data; struct sge_qset *qs = (struct sge_qset *)data;
struct sge_txq *q = &qs->txq[TXQ_CTRL]; 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); spin_lock(&q->lock);
again:reclaim_completed_tx_imm(q); again:reclaim_completed_tx_imm(q);
...@@ -1531,7 +1532,8 @@ static void restart_offloadq(unsigned long data) ...@@ -1531,7 +1532,8 @@ static void restart_offloadq(unsigned long data)
struct sk_buff *skb; struct sk_buff *skb;
struct sge_qset *qs = (struct sge_qset *)data; struct sge_qset *qs = (struct sge_qset *)data;
struct sge_txq *q = &qs->txq[TXQ_OFLD]; 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); spin_lock(&q->lock);
again:reclaim_completed_tx(adap, q); again:reclaim_completed_tx(adap, q);
...@@ -1675,7 +1677,8 @@ static inline void deliver_partial_bundle(struct t3cdev *tdev, ...@@ -1675,7 +1677,8 @@ static inline void deliver_partial_bundle(struct t3cdev *tdev,
*/ */
static int ofld_poll(struct net_device *dev, int *budget) 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_qset *qs = dev2qset(dev);
struct sge_rspq *q = &qs->rspq; struct sge_rspq *q = &qs->rspq;
int work_done, limit = min(*budget, dev->quota), avail = limit; 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,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) 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); struct sge_qset *qs = dev2qset(dev);
int effective_budget = min(*budget, dev->quota); int effective_budget = min(*budget, dev->quota);
...@@ -2205,7 +2209,8 @@ static inline int handle_responses(struct adapter *adap, struct sge_rspq *q) ...@@ -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) irqreturn_t t3_sge_intr_msix(int irq, void *cookie)
{ {
struct sge_qset *qs = 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; struct sge_rspq *q = &qs->rspq;
spin_lock(&q->lock); spin_lock(&q->lock);
...@@ -2224,7 +2229,8 @@ irqreturn_t t3_sge_intr_msix(int irq, void *cookie) ...@@ -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) irqreturn_t t3_sge_intr_msix_napi(int irq, void *cookie)
{ {
struct sge_qset *qs = 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; struct sge_rspq *q = &qs->rspq;
spin_lock(&q->lock); spin_lock(&q->lock);
...@@ -2508,7 +2514,8 @@ static void sge_timer_cb(unsigned long data) ...@@ -2508,7 +2514,8 @@ static void sge_timer_cb(unsigned long data)
{ {
spinlock_t *lock; spinlock_t *lock;
struct sge_qset *qs = (struct sge_qset *)data; 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)) { if (spin_trylock(&qs->txq[TXQ_ETH].lock)) {
reclaim_completed_tx(adap, &qs->txq[TXQ_ETH]); reclaim_completed_tx(adap, &qs->txq[TXQ_ETH]);
......
...@@ -42,9 +42,6 @@ ...@@ -42,9 +42,6 @@
#define T3CNAMSIZ 16 #define T3CNAMSIZ 16
/* Get the t3cdev associated with a net_device */
#define T3CDEV(netdev) (struct t3cdev *)(netdev->priv)
struct cxgb3_client; struct cxgb3_client;
enum t3ctype { enum t3ctype {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment