[PATCH] myri10ge: add page-based skb routines
[deliverable/linux.git] / drivers / net / myri10ge / myri10ge.c
index 4330197994dfcdb1476687c208269165ee721060..05b4f93518f55587d8e48c52d4a96a773daecce7 100644 (file)
@@ -89,11 +89,17 @@ MODULE_LICENSE("Dual BSD/GPL");
 #define MYRI10GE_EEPROM_STRINGS_SIZE 256
 #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
 
-#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff
+#define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
 #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
 
+#define MYRI10GE_ALLOC_ORDER 0
+#define MYRI10GE_ALLOC_SIZE ((1 << MYRI10GE_ALLOC_ORDER) * PAGE_SIZE)
+#define MYRI10GE_MAX_FRAGS_PER_FRAME (MYRI10GE_MAX_ETHER_MTU/MYRI10GE_ALLOC_SIZE + 1)
+
 struct myri10ge_rx_buffer_state {
        struct sk_buff *skb;
+       struct page *page;
+       int page_offset;
         DECLARE_PCI_UNMAP_ADDR(bus)
         DECLARE_PCI_UNMAP_LEN(len)
 };
@@ -116,9 +122,14 @@ struct myri10ge_rx_buf {
        u8 __iomem *wc_fifo;    /* w/c rx dma addr fifo address */
        struct mcp_kreq_ether_recv *shadow;     /* host shadow of recv ring */
        struct myri10ge_rx_buffer_state *info;
+       struct page *page;
+       dma_addr_t bus;
+       int page_offset;
        int cnt;
+       int fill_cnt;
        int alloc_fail;
        int mask;               /* number of rx slots -1 */
+       int watchdog_needed;
 };
 
 struct myri10ge_tx_buf {
@@ -150,14 +161,15 @@ struct myri10ge_priv {
        struct myri10ge_rx_buf rx_big;
        struct myri10ge_rx_done rx_done;
        int small_bytes;
+       int big_bytes;
        struct net_device *dev;
        struct net_device_stats stats;
        u8 __iomem *sram;
        int sram_size;
        unsigned long board_span;
        unsigned long iomem_base;
-       u32 __iomem *irq_claim;
-       u32 __iomem *irq_deassert;
+       __be32 __iomem *irq_claim;
+       __be32 __iomem *irq_deassert;
        char *mac_addr_string;
        struct mcp_cmd_response *cmd;
        dma_addr_t cmd_bus;
@@ -165,10 +177,10 @@ struct myri10ge_priv {
        dma_addr_t fw_stats_bus;
        struct pci_dev *pdev;
        int msi_enabled;
-       unsigned int link_state;
+       __be32 link_state;
        unsigned int rdma_tags_available;
        int intr_coal_delay;
-       u32 __iomem *intr_coal_delay_ptr;
+       __be32 __iomem *intr_coal_delay_ptr;
        int mtrr;
        int wake_queue;
        int stop_queue;
@@ -266,6 +278,10 @@ static int myri10ge_debug = -1;    /* defaults above */
 module_param(myri10ge_debug, int, 0);
 MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
+static int myri10ge_fill_thresh = 256;
+module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed\n");
+
 #define MYRI10GE_FW_OFFSET 1024*1024
 #define MYRI10GE_HIGHPART_TO_U32(X) \
 (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
@@ -273,6 +289,11 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
 
 #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
 
+static inline void put_be32(__be32 val, __be32 __iomem * p)
+{
+       __raw_writel((__force __u32) val, (__force void __iomem *)p);
+}
+
 static int
 myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                  struct myri10ge_cmd *data, int atomic)
@@ -296,7 +317,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
 
        buf->response_addr.low = htonl(dma_low);
        buf->response_addr.high = htonl(dma_high);
-       response->result = MYRI10GE_NO_RESPONSE_RESULT;
+       response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT);
        mb();
        myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
 
@@ -311,14 +332,14 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
                 * (1ms will be enough for those commands) */
                for (sleep_total = 0;
                     sleep_total < 1000
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
                     sleep_total += 10)
                        udelay(10);
        } else {
                /* use msleep for most command */
                for (sleep_total = 0;
                     sleep_total < 15
-                    && response->result == MYRI10GE_NO_RESPONSE_RESULT;
+                    && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
                     sleep_total++)
                        msleep(1);
        }
@@ -393,7 +414,7 @@ abort:
 static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16];
        u32 dma_low, dma_high;
        int i;
 
@@ -410,7 +431,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
        buf[3] = htonl(dma_high);       /* dummy addr MSW */
        buf[4] = htonl(dma_low);        /* dummy addr LSW */
        buf[5] = htonl(enable); /* enable? */
@@ -479,7 +500,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
        }
 
        /* check id */
-       hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
+       hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
        if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
                dev_err(dev, "Bad firmware file\n");
                status = -EINVAL;
@@ -550,7 +571,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
 static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
 {
        char __iomem *submit;
-       u32 buf[16];
+       __be32 buf[16];
        u32 dma_low, dma_high, size;
        int status, i;
 
@@ -600,7 +621,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
 
        buf[0] = htonl(dma_high);       /* confirm addr MSW */
        buf[1] = htonl(dma_low);        /* confirm addr LSW */
-       buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA);       /* confirm data */
+       buf[2] = MYRI10GE_NO_CONFIRM_DATA;      /* confirm data */
 
        /* FIX: All newest firmware should un-protect the bottom of
         * the sram before handoff. However, the very first interfaces
@@ -705,21 +726,21 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
 
        status |=
            myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
-       mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0);
+       mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
        if (!mgp->msi_enabled) {
                status |= myri10ge_send_cmd
                    (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
-               mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0);
+               mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
 
        }
        status |= myri10ge_send_cmd
            (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
-       mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0);
+       mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0);
        if (status != 0) {
                dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
                return status;
        }
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
 
        /* Run a small DMA test.
         * The magic multipliers to the length tell the firmware
@@ -786,14 +807,16 @@ static inline void
 myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
                    struct mcp_kreq_ether_recv *src)
 {
-       u32 low;
+       __be32 low;
 
        low = src->addr_low;
-       src->addr_low = DMA_32BIT_MASK;
-       myri10ge_pio_copy(dst, src, 8 * sizeof(*src));
+       src->addr_low = htonl(DMA_32BIT_MASK);
+       myri10ge_pio_copy(dst, src, 4 * sizeof(*src));
+       mb();
+       myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
        mb();
        src->addr_low = low;
-       __raw_writel(low, &dst->addr_low);
+       put_be32(low, &dst->addr_low);
        mb();
 }
 
@@ -939,11 +962,11 @@ done:
        return retval;
 }
 
-static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
+static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum)
 {
        struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
 
-       if ((skb->protocol == ntohs(ETH_P_8021Q)) &&
+       if ((skb->protocol == htons(ETH_P_8021Q)) &&
            (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
             vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
                skb->csum = hw_csum;
@@ -951,9 +974,183 @@ static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
        }
 }
 
+static inline void
+myri10ge_rx_skb_build(struct sk_buff *skb, u8 * va,
+                     struct skb_frag_struct *rx_frags, int len, int hlen)
+{
+       struct skb_frag_struct *skb_frags;
+
+       skb->len = skb->data_len = len;
+       skb->truesize = len + sizeof(struct sk_buff);
+       /* attach the page(s) */
+
+       skb_frags = skb_shinfo(skb)->frags;
+       while (len > 0) {
+               memcpy(skb_frags, rx_frags, sizeof(*skb_frags));
+               len -= rx_frags->size;
+               skb_frags++;
+               rx_frags++;
+               skb_shinfo(skb)->nr_frags++;
+       }
+
+       /* pskb_may_pull is not available in irq context, but
+        * skb_pull() (for ether_pad and eth_type_trans()) requires
+        * the beginning of the packet in skb_headlen(), move it
+        * manually */
+       memcpy(skb->data, va, hlen);
+       skb_shinfo(skb)->frags[0].page_offset += hlen;
+       skb_shinfo(skb)->frags[0].size -= hlen;
+       skb->data_len -= hlen;
+       skb->tail += hlen;
+       skb_pull(skb, MXGEFW_PAD);
+}
+
+static void
+myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
+                       int bytes, int watchdog)
+{
+       struct page *page;
+       int idx;
+
+       if (unlikely(rx->watchdog_needed && !watchdog))
+               return;
+
+       /* try to refill entire ring */
+       while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) {
+               idx = rx->fill_cnt & rx->mask;
+
+               if ((bytes < MYRI10GE_ALLOC_SIZE / 2) &&
+                   (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE)) {
+                       /* we can use part of previous page */
+                       get_page(rx->page);
+               } else {
+                       /* we need a new page */
+                       page =
+                           alloc_pages(GFP_ATOMIC | __GFP_COMP,
+                                       MYRI10GE_ALLOC_ORDER);
+                       if (unlikely(page == NULL)) {
+                               if (rx->fill_cnt - rx->cnt < 16)
+                                       rx->watchdog_needed = 1;
+                               return;
+                       }
+                       rx->page = page;
+                       rx->page_offset = 0;
+                       rx->bus = pci_map_page(mgp->pdev, page, 0,
+                                              MYRI10GE_ALLOC_SIZE,
+                                              PCI_DMA_FROMDEVICE);
+               }
+               rx->info[idx].page = rx->page;
+               rx->info[idx].page_offset = rx->page_offset;
+               /* note that this is the address of the start of the
+                * page */
+               pci_unmap_addr_set(&rx->info[idx], bus, rx->bus);
+               rx->shadow[idx].addr_low =
+                   htonl(MYRI10GE_LOWPART_TO_U32(rx->bus) + rx->page_offset);
+               rx->shadow[idx].addr_high =
+                   htonl(MYRI10GE_HIGHPART_TO_U32(rx->bus));
+
+               /* start next packet on a cacheline boundary */
+               rx->page_offset += SKB_DATA_ALIGN(bytes);
+               rx->fill_cnt++;
+
+               /* copy 8 descriptors to the firmware at a time */
+               if ((idx & 7) == 7) {
+                       if (rx->wc_fifo == NULL)
+                               myri10ge_submit_8rx(&rx->lanai[idx - 7],
+                                                   &rx->shadow[idx - 7]);
+                       else {
+                               mb();
+                               myri10ge_pio_copy(rx->wc_fifo,
+                                                 &rx->shadow[idx - 7], 64);
+                       }
+               }
+       }
+}
+
+static inline void
+myri10ge_unmap_rx_page(struct pci_dev *pdev,
+                      struct myri10ge_rx_buffer_state *info, int bytes)
+{
+       /* unmap the recvd page if we're the only or last user of it */
+       if (bytes >= MYRI10GE_ALLOC_SIZE / 2 ||
+           (info->page_offset + 2 * bytes) > MYRI10GE_ALLOC_SIZE) {
+               pci_unmap_page(pdev, (pci_unmap_addr(info, bus)
+                                     & ~(MYRI10GE_ALLOC_SIZE - 1)),
+                              MYRI10GE_ALLOC_SIZE, PCI_DMA_FROMDEVICE);
+       }
+}
+
+#define MYRI10GE_HLEN 64       /* The number of bytes to copy from a
+                                * page into an skb */
+
+static inline int
+myri10ge_page_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
+                     int bytes, int len, __wsum csum)
+{
+       struct sk_buff *skb;
+       struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME];
+       int i, idx, hlen, remainder;
+       struct pci_dev *pdev = mgp->pdev;
+       struct net_device *dev = mgp->dev;
+       u8 *va;
+
+       len += MXGEFW_PAD;
+       idx = rx->cnt & rx->mask;
+       va = page_address(rx->info[idx].page) + rx->info[idx].page_offset;
+       prefetch(va);
+       /* Fill skb_frag_struct(s) with data from our receive */
+       for (i = 0, remainder = len; remainder > 0; i++) {
+               myri10ge_unmap_rx_page(pdev, &rx->info[idx], bytes);
+               rx_frags[i].page = rx->info[idx].page;
+               rx_frags[i].page_offset = rx->info[idx].page_offset;
+               if (remainder < MYRI10GE_ALLOC_SIZE)
+                       rx_frags[i].size = remainder;
+               else
+                       rx_frags[i].size = MYRI10GE_ALLOC_SIZE;
+               rx->cnt++;
+               idx = rx->cnt & rx->mask;
+               remainder -= MYRI10GE_ALLOC_SIZE;
+       }
+
+       hlen = MYRI10GE_HLEN > len ? len : MYRI10GE_HLEN;
+
+       /* allocate an skb to attach the page(s) to. */
+
+       skb = netdev_alloc_skb(dev, MYRI10GE_HLEN + 16);
+       if (unlikely(skb == NULL)) {
+               mgp->stats.rx_dropped++;
+               do {
+                       i--;
+                       put_page(rx_frags[i].page);
+               } while (i != 0);
+               return 0;
+       }
+
+       /* Attach the pages to the skb, and trim off any padding */
+       myri10ge_rx_skb_build(skb, va, rx_frags, len, hlen);
+       if (skb_shinfo(skb)->frags[0].size <= 0) {
+               put_page(skb_shinfo(skb)->frags[0].page);
+               skb_shinfo(skb)->nr_frags = 0;
+       }
+       skb->protocol = eth_type_trans(skb, dev);
+       skb->dev = dev;
+
+       if (mgp->csum_flag) {
+               if ((skb->protocol == htons(ETH_P_IP)) ||
+                   (skb->protocol == htons(ETH_P_IPV6))) {
+                       skb->csum = csum;
+                       skb->ip_summed = CHECKSUM_COMPLETE;
+               } else
+                       myri10ge_vlan_ip_csum(skb, csum);
+       }
+       netif_receive_skb(skb);
+       dev->last_rx = jiffies;
+       return 1;
+}
+
 static inline unsigned long
 myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
-                int bytes, int len, int csum)
+                int bytes, int len, __wsum csum)
 {
        dma_addr_t bus;
        struct sk_buff *skb;
@@ -986,12 +1183,12 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
 
        skb->protocol = eth_type_trans(skb, mgp->dev);
        if (mgp->csum_flag) {
-               if ((skb->protocol == ntohs(ETH_P_IP)) ||
-                   (skb->protocol == ntohs(ETH_P_IPV6))) {
-                       skb->csum = ntohs((u16) csum);
+               if ((skb->protocol == htons(ETH_P_IP)) ||
+                   (skb->protocol == htons(ETH_P_IPV6))) {
+                       skb->csum = csum;
                        skb->ip_summed = CHECKSUM_COMPLETE;
                } else
-                       myri10ge_vlan_ip_csum(skb, ntohs((u16) csum));
+                       myri10ge_vlan_ip_csum(skb, csum);
        }
 
        netif_receive_skb(skb);
@@ -1060,12 +1257,12 @@ static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
        int idx = rx_done->idx;
        int cnt = rx_done->cnt;
        u16 length;
-       u16 checksum;
+       __wsum checksum;
 
        while (rx_done->entry[idx].length != 0 && *limit != 0) {
                length = ntohs(rx_done->entry[idx].length);
                rx_done->entry[idx].length = 0;
-               checksum = ntohs(rx_done->entry[idx].checksum);
+               checksum = csum_unfold(rx_done->entry[idx].checksum);
                if (length <= mgp->small_bytes)
                        rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
                                                 mgp->small_bytes,
@@ -1142,13 +1339,13 @@ static int myri10ge_poll(struct net_device *netdev, int *budget)
 
        if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
                netif_rx_complete(netdev);
-               __raw_writel(htonl(3), mgp->irq_claim);
+               put_be32(htonl(3), mgp->irq_claim);
                return 0;
        }
        return 1;
 }
 
-static irqreturn_t myri10ge_intr(int irq, void *arg, struct pt_regs *regs)
+static irqreturn_t myri10ge_intr(int irq, void *arg)
 {
        struct myri10ge_priv *mgp = arg;
        struct mcp_irq_data *stats = mgp->fw_stats;
@@ -1166,7 +1363,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg, struct pt_regs *regs)
                netif_rx_schedule(mgp->dev);
 
        if (!mgp->msi_enabled) {
-               __raw_writel(0, mgp->irq_deassert);
+               put_be32(0, mgp->irq_deassert);
                if (!myri10ge_deassert_wait)
                        stats->valid = 0;
                mb();
@@ -1195,7 +1392,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg, struct pt_regs *regs)
 
        myri10ge_check_statblock(mgp);
 
-       __raw_writel(htonl(3), mgp->irq_claim + 1);
+       put_be32(htonl(3), mgp->irq_claim + 1);
        return (IRQ_HANDLED);
 }
 
@@ -1233,7 +1430,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
        struct myri10ge_priv *mgp = netdev_priv(netdev);
 
        mgp->intr_coal_delay = coal->rx_coalesce_usecs;
-       __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
+       put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
        return 0;
 }
 
@@ -1748,7 +1945,7 @@ static int myri10ge_open(struct net_device *dev)
                goto abort_with_rings;
        }
 
-       mgp->link_state = -1;
+       mgp->link_state = htonl(~0U);
        mgp->rdma_tags_available = 15;
 
        netif_poll_enable(mgp->dev);    /* must happen prior to any irq */
@@ -1876,7 +2073,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
 
        /* re-write the last 32-bits with the valid flags */
        src->flags = last_flags;
-       __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3);
+       put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
        tx->req += cnt;
        mb();
 }
@@ -1919,7 +2116,8 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
        struct myri10ge_tx_buf *tx = &mgp->tx;
        struct skb_frag_struct *frag;
        dma_addr_t bus;
-       u32 low, high_swapped;
+       u32 low;
+       __be32 high_swapped;
        unsigned int len;
        int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
        u16 pseudo_hdr_offset, cksum_offset;
@@ -1955,7 +2153,7 @@ again:
        flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST);
        if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
                cksum_offset = (skb->h.raw - skb->data);
-               pseudo_hdr_offset = (skb->h.raw + skb->csum) - skb->data;
+               pseudo_hdr_offset = cksum_offset + skb->csum_offset;
                /* If the headers are excessively large, then we must
                 * fall back to a software checksum */
                if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) {
@@ -1964,7 +2162,6 @@ again:
                        cksum_offset = 0;
                        pseudo_hdr_offset = 0;
                } else {
-                       pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
                        flags |= MXGEFW_FLAGS_CKSUM;
                }
@@ -1986,7 +2183,7 @@ again:
                /* for TSO, pseudo_hdr_offset holds mss.
                 * The firmware figures out where to put
                 * the checksum by parsing the header. */
-               pseudo_hdr_offset = htons(mss);
+               pseudo_hdr_offset = mss;
        } else
 #endif                         /*NETIF_F_TSO */
                /* Mark small packets, and pad out tiny packets */
@@ -2086,7 +2283,7 @@ again:
 #endif                         /* NETIF_F_TSO */
                        req->addr_high = high_swapped;
                        req->addr_low = htonl(low);
-                       req->pseudo_hdr_offset = pseudo_hdr_offset;
+                       req->pseudo_hdr_offset = htons(pseudo_hdr_offset);
                        req->pad = 0;   /* complete solid 16-byte block; does this matter? */
                        req->rdma_count = 1;
                        req->length = htons(seglen);
@@ -2199,6 +2396,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
        struct myri10ge_cmd cmd;
        struct myri10ge_priv *mgp;
        struct dev_mc_list *mc_list;
+       __be32 data[2] = { 0, 0 };
        int err;
 
        mgp = netdev_priv(dev);
@@ -2237,10 +2435,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
 
        /* Walk the multicast list, and add each address */
        for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
-               memcpy(&cmd.data0, &mc_list->dmi_addr, 4);
-               memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2);
-               cmd.data0 = htonl(cmd.data0);
-               cmd.data1 = htonl(cmd.data1);
+               memcpy(data, &mc_list->dmi_addr, 6);
+               cmd.data0 = ntohl(data[0]);
+               cmd.data1 = ntohl(data[1]);
                err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
                                        &cmd, 1);
 
@@ -2416,7 +2613,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
  * firmware image, and set tx.boundary to 4KB.
  */
 
-#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE  0x0132
 #define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
 #define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
 
@@ -2616,9 +2812,10 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
  * This watchdog is used to check whether the board has suffered
  * from a parity error and needs to be recovered.
  */
-static void myri10ge_watchdog(void *arg)
+static void myri10ge_watchdog(struct work_struct *work)
 {
-       struct myri10ge_priv *mgp = arg;
+       struct myri10ge_priv *mgp =
+           container_of(work, struct myri10ge_priv, watchdog_work);
        u32 reboot;
        int status;
        u16 cmd, vendor;
@@ -2888,7 +3085,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                    (unsigned long)mgp);
 
        SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
-       INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp);
+       INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
        status = register_netdev(netdev);
        if (status != 0) {
                dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
This page took 0.037473 seconds and 5 git commands to generate.