include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / message / fusion / mptlan.c
index 582a921..4fa9665 100644 (file)
@@ -56,6 +56,8 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
 
 #define my_VERSION     MPT_LINUX_VERSION_COMMON
 #define MYNAM          "mptlan"
@@ -77,12 +79,6 @@ MODULE_VERSION(my_VERSION);
  *  Fusion MPT LAN private structures
  */
 
-struct NAA_Hosed {
-       u16 NAA;
-       u8 ieee[FC_ALEN];
-       struct NAA_Hosed *next;
-};
-
 struct BufferControl {
        struct sk_buff  *skb;
        dma_addr_t      dma;
@@ -112,7 +108,6 @@ struct mpt_lan_priv {
 
        u32 total_posted;
        u32 total_received;
-       struct net_device_stats stats;  /* Per device statistics */
 
        struct delayed_work post_buckets_task;
        struct net_device *dev;
@@ -159,11 +154,6 @@ static u8 LanCtx = MPT_MAX_PROTOCOL_DRIVERS;
 static u32 max_buckets_out = 127;
 static u32 tx_max_out_p = 127 - 16;
 
-#ifdef QLOGIC_NAA_WORKAROUND
-static struct NAA_Hosed *mpt_bad_naa = NULL;
-DEFINE_RWLOCK(bad_naa_lock);
-#endif
-
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *     lan_reply - Handle all data sent from the hardware.
@@ -559,15 +549,6 @@ mpt_lan_close(struct net_device *dev)
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-static struct net_device_stats *
-mpt_lan_get_stats(struct net_device *dev)
-{
-       struct mpt_lan_priv *priv = netdev_priv(dev);
-
-       return (struct net_device_stats *) &priv->stats;
-}
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 static int
 mpt_lan_change_mtu(struct net_device *dev, int new_mtu)
 {
@@ -605,8 +586,8 @@ mpt_lan_send_turbo(struct net_device *dev, u32 tmsg)
        ctx = GET_LAN_BUFFER_CONTEXT(tmsg);
        sent = priv->SendCtl[ctx].skb;
 
-       priv->stats.tx_packets++;
-       priv->stats.tx_bytes += sent->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes += sent->len;
 
        dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
                        IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -647,7 +628,7 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
 
        switch (le16_to_cpu(pSendRep->IOCStatus) & MPI_IOCSTATUS_MASK) {
        case MPI_IOCSTATUS_SUCCESS:
-               priv->stats.tx_packets += count;
+               dev->stats.tx_packets += count;
                break;
 
        case MPI_IOCSTATUS_LAN_CANCELED:
@@ -655,13 +636,13 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
                break;
 
        case MPI_IOCSTATUS_INVALID_SGL:
-               priv->stats.tx_errors += count;
+               dev->stats.tx_errors += count;
                printk (KERN_ERR MYNAM ": %s/%s: ERROR - Invalid SGL sent to IOC!\n",
                                IOC_AND_NETDEV_NAMES_s_s(dev));
                goto out;
 
        default:
-               priv->stats.tx_errors += count;
+               dev->stats.tx_errors += count;
                break;
        }
 
@@ -672,7 +653,7 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
                ctx = GET_LAN_BUFFER_CONTEXT(le32_to_cpu(*pContext));
 
                sent = priv->SendCtl[ctx].skb;
-               priv->stats.tx_bytes += sent->len;
+               dev->stats.tx_bytes += sent->len;
 
                dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
                                IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -724,7 +705,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
 
                printk (KERN_ERR "%s: no tx context available: %u\n",
                        __func__, priv->mpt_txfidx_tail);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        mf = mpt_get_msg_frame(LanCtx, mpt_dev);
@@ -734,7 +715,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
 
                printk (KERN_ERR "%s: Unable to alloc request frame\n",
                        __func__);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
 
        ctx = priv->mpt_txfidx[priv->mpt_txfidx_tail--];
@@ -780,30 +761,6 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
 //                     ctx, skb, skb->data));
 
        mac = skb_mac_header(skb);
-#ifdef QLOGIC_NAA_WORKAROUND
-{
-       struct NAA_Hosed *nh;
-
-       /* Munge the NAA for Tx packets to QLogic boards, which don't follow
-          RFC 2625. The longer I look at this, the more my opinion of Qlogic
-          drops. */
-       read_lock_irq(&bad_naa_lock);
-       for (nh = mpt_bad_naa; nh != NULL; nh=nh->next) {
-               if ((nh->ieee[0] == mac[0]) &&
-                   (nh->ieee[1] == mac[1]) &&
-                   (nh->ieee[2] == mac[2]) &&
-                   (nh->ieee[3] == mac[3]) &&
-                   (nh->ieee[4] == mac[4]) &&
-                   (nh->ieee[5] == mac[5])) {
-                       cur_naa = nh->NAA;
-                       dlprintk ((KERN_INFO "mptlan/sdu_send: using NAA value "
-                                 "= %04x.\n", cur_naa));
-                       break;
-               }
-       }
-       read_unlock_irq(&bad_naa_lock);
-}
-#endif
 
        pTrans->TransactionDetails[0] = cpu_to_le32((cur_naa         << 16) |
                                                    (mac[0] <<  8) |
@@ -840,7 +797,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, struct net_device *dev)
                        IOC_AND_NETDEV_NAMES_s_s(dev),
                        le32_to_cpu(pSimple->FlagsLength)));
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -850,7 +807,7 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
  * @priority: 0 = put it on the timer queue, 1 = put it on the immediate queue
  */
 {
-       struct mpt_lan_priv *priv = dev->priv;
+       struct mpt_lan_priv *priv = netdev_priv(dev);
        
        if (test_and_set_bit(0, &priv->post_buckets_active) == 0) {
                if (priority) {
@@ -869,7 +826,7 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
 static int
 mpt_lan_receive_skb(struct net_device *dev, struct sk_buff *skb)
 {
-       struct mpt_lan_priv *priv = dev->priv;
+       struct mpt_lan_priv *priv = netdev_priv(dev);
 
        skb->protocol = mpt_lan_type_trans(skb, dev);
 
@@ -877,8 +834,8 @@ mpt_lan_receive_skb(struct net_device *dev, struct sk_buff *skb)
                 "delivered to upper level.\n",
                        IOC_AND_NETDEV_NAMES_s_s(dev), skb->len));
 
-       priv->stats.rx_bytes += skb->len;
-       priv->stats.rx_packets++;
+       dev->stats.rx_bytes += skb->len;
+       dev->stats.rx_packets++;
 
        skb->dev = dev;
        netif_rx(skb);
@@ -901,7 +858,7 @@ mpt_lan_receive_skb(struct net_device *dev, struct sk_buff *skb)
 static int
 mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg)
 {
-       struct mpt_lan_priv *priv = dev->priv;
+       struct mpt_lan_priv *priv = netdev_priv(dev);
        MPT_ADAPTER *mpt_dev = priv->mpt_dev;
        struct sk_buff *skb, *old_skb;
        unsigned long flags;
@@ -956,7 +913,7 @@ static int
 mpt_lan_receive_post_free(struct net_device *dev,
                          LANReceivePostReply_t *pRecvRep)
 {
-       struct mpt_lan_priv *priv = dev->priv;
+       struct mpt_lan_priv *priv = netdev_priv(dev);
        MPT_ADAPTER *mpt_dev = priv->mpt_dev;
        unsigned long flags;
        struct sk_buff *skb;
@@ -1011,7 +968,7 @@ static int
 mpt_lan_receive_post_reply(struct net_device *dev,
                           LANReceivePostReply_t *pRecvRep)
 {
-       struct mpt_lan_priv *priv = dev->priv;
+       struct mpt_lan_priv *priv = netdev_priv(dev);
        MPT_ADAPTER *mpt_dev = priv->mpt_dev;
        struct sk_buff *skb, *old_skb;
        unsigned long flags;
@@ -1343,6 +1300,14 @@ mpt_lan_post_receive_buckets_work(struct work_struct *work)
                                                  post_buckets_task.work));
 }
 
+static const struct net_device_ops mpt_netdev_ops = {
+       .ndo_open       = mpt_lan_open,
+       .ndo_stop       = mpt_lan_close,
+       .ndo_start_xmit = mpt_lan_sdu_send,
+       .ndo_change_mtu = mpt_lan_change_mtu,
+       .ndo_tx_timeout = mpt_lan_tx_timeout,
+};
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 static struct net_device *
 mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
@@ -1407,15 +1372,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
        priv->tx_max_out = (tx_max_out_p <= MPT_TX_MAX_OUT_LIM) ?
                            tx_max_out_p : MPT_TX_MAX_OUT_LIM;
 
-       dev->open = mpt_lan_open;
-       dev->stop = mpt_lan_close;
-       dev->get_stats = mpt_lan_get_stats;
-       dev->set_multicast_list = NULL;
-       dev->change_mtu = mpt_lan_change_mtu;
-       dev->hard_start_xmit = mpt_lan_sdu_send;
-
-/* Not in 2.3.42. Need 2.3.45+ */
-       dev->tx_timeout = mpt_lan_tx_timeout;
+       dev->netdev_ops = &mpt_netdev_ops;
        dev->watchdog_timeo = MPT_LAN_TX_TIMEOUT;
 
        dlprintk((KERN_INFO MYNAM ": Finished registering dev "
@@ -1569,79 +1526,6 @@ mpt_lan_type_trans(struct sk_buff *skb, struct net_device *dev)
 
        fcllc = (struct fcllc *)skb->data;
 
-#ifdef QLOGIC_NAA_WORKAROUND
-{
-       u16 source_naa = fch->stype, found = 0;
-
-       /* Workaround for QLogic not following RFC 2625 in regards to the NAA
-          value. */
-
-       if ((source_naa & 0xF000) == 0)
-               source_naa = swab16(source_naa);
-
-       if (fcllc->ethertype == htons(ETH_P_ARP))
-           dlprintk ((KERN_INFO "mptlan/type_trans: got arp req/rep w/ naa of "
-                     "%04x.\n", source_naa));
-
-       if ((fcllc->ethertype == htons(ETH_P_ARP)) &&
-          ((source_naa >> 12) !=  MPT_LAN_NAA_RFC2625)){
-               struct NAA_Hosed *nh, *prevnh;
-               int i;
-
-               dlprintk ((KERN_INFO "mptlan/type_trans: ARP Req/Rep from "
-                         "system with non-RFC 2625 NAA value (%04x).\n",
-                         source_naa));
-
-               write_lock_irq(&bad_naa_lock);
-               for (prevnh = nh = mpt_bad_naa; nh != NULL;
-                    prevnh=nh, nh=nh->next) {
-                       if ((nh->ieee[0] == fch->saddr[0]) &&
-                           (nh->ieee[1] == fch->saddr[1]) &&
-                           (nh->ieee[2] == fch->saddr[2]) &&
-                           (nh->ieee[3] == fch->saddr[3]) &&
-                           (nh->ieee[4] == fch->saddr[4]) &&
-                           (nh->ieee[5] == fch->saddr[5])) {
-                               found = 1;
-                               dlprintk ((KERN_INFO "mptlan/type_trans: ARP Re"
-                                        "q/Rep w/ bad NAA from system already"
-                                        " in DB.\n"));
-                               break;
-                       }
-               }
-
-               if ((!found) && (nh == NULL)) {
-
-                       nh = kmalloc(sizeof(struct NAA_Hosed), GFP_KERNEL);
-                       dlprintk ((KERN_INFO "mptlan/type_trans: ARP Req/Rep w/"
-                                " bad NAA from system not yet in DB.\n"));
-
-                       if (nh != NULL) {
-                               nh->next = NULL;
-                               if (!mpt_bad_naa)
-                                       mpt_bad_naa = nh;
-                               if (prevnh)
-                                       prevnh->next = nh;
-
-                               nh->NAA = source_naa; /* Set the S_NAA value. */
-                               for (i = 0; i < FC_ALEN; i++)
-                                       nh->ieee[i] = fch->saddr[i];
-                               dlprintk ((KERN_INFO "Got ARP from %pM with"
-                                         " non-compliant S_NAA value.\n",
-                                         fch->saddr));
-                       } else {
-                               printk (KERN_ERR "mptlan/type_trans: Unable to"
-                                       " kmalloc a NAA_Hosed struct.\n");
-                       }
-               } else if (!found) {
-                       printk (KERN_ERR "mptlan/type_trans: found not"
-                               " set, but nh isn't null. Evil "
-                               "funkiness abounds.\n");
-               }
-               write_unlock_irq(&bad_naa_lock);
-       }
-}
-#endif
-
        /* Strip the SNAP header from ARP packets since we don't
         * pass them through to the 802.2/SNAP layers.
         */