BNX2X: hacked up receive
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 26 Feb 2015 21:49:36 +0000 (16:49 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 Mar 2015 16:59:11 +0000 (11:59 -0500)
Can receive ARPs and forwards them to devether.  Will panic on tx_int.

kern/drivers/net/bnx2x/akaros_compat.h
kern/drivers/net/bnx2x/bnx2x_cmn.c
kern/drivers/net/bnx2x/bnx2x_dev.c
kern/drivers/net/bnx2x/bnx2x_main.c

index e7a10b3..ce9015d 100644 (file)
@@ -659,7 +659,7 @@ static int pcie_capability_read_word(struct pci_device *dev, int pos,
 #define netif_running(dev) (TRUE)
 
 #define EPROBE_DEFER 1
-#define NET_SKB_PAD 32         /* we'll probably delete code using this */
+#define NET_SKB_PAD 0          /* padding for SKBs.  Ignoring it for now */
 #define MAX_SKB_FRAGS 16       /* we'll probably delete code using this */
 #define VLAN_VID_MASK 0x0fff /* VLAN Identifier */
 
index 3353423..0553809 100644 (file)
@@ -901,6 +901,8 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
        union eth_rx_cqe *cqe;
        struct eth_fast_path_rx_cqe *cqe_fp;
 
+       struct block *block;
+
 #ifdef BNX2X_STOP_ON_ERROR
        if (unlikely(bp->panic))
                return 0;
@@ -966,8 +968,6 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
                        goto next_cqe;
                }
 
-panic("Not implemented");
-#if 0 // AKAROS_PORT
                rx_buf = &fp->rx_buf_ring[bd_cons];
                data = rx_buf->data;
 
@@ -1042,16 +1042,19 @@ panic("Not implemented");
                /* Since we don't have a jumbo ring
                 * copy small packets if mtu > 1500
                 */
-               if ((bp->dev->maxmtu > ETH_MAX_PACKET_SIZE) &&
-                   (len <= RX_COPY_THRESH)) {
-                       skb = napi_alloc_skb(&fp->napi, len);
-                       if (skb == NULL) {
+               /* TODO: AKAROS_PORT always copy out the packet for now. */
+               if (1) {
+//             if ((bp->dev->maxmtu > ETH_MAX_PACKET_SIZE) &&
+//                 (len <= RX_COPY_THRESH)) {
+                       block = iallocb(len);
+                       if (block == NULL) {
                                DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS,
                                   "ERROR  packet dropped because of alloc failure\n");
                                bnx2x_fp_qstats(bp, fp)->rx_skb_alloc_failed++;
                                goto reuse_rx;
                        }
-                       memcpy(skb->data, data + pad, len);
+                       memcpy(block->wp, data + pad, len);
+                       block->wp += len;
                        bnx2x_reuse_rx_data(fp, bd_cons, bd_prod);
                } else {
                        if (likely(bnx2x_alloc_rx_data(bp, fp, bd_prod,
@@ -1060,6 +1063,9 @@ panic("Not implemented");
                                                 dma_unmap_addr(rx_buf, mapping),
                                                 fp->rx_buf_size,
                                                 DMA_FROM_DEVICE);
+                               /* TODO: block extra data here */
+                               panic("Extra-data not implemented");
+                               #if 0 // AKAROS_PORT
                                skb = build_skb(data, fp->rx_frag_size);
                                if (unlikely(!skb)) {
                                        bnx2x_frag_free(fp, data);
@@ -1068,6 +1074,7 @@ panic("Not implemented");
                                        goto next_rx;
                                }
                                skb_reserve(skb, pad);
+                               #endif
                        } else {
                                DP(NETIF_MSG_RX_ERR | NETIF_MSG_RX_STATUS,
                                   "ERROR  packet dropped because of alloc failure\n");
@@ -1078,6 +1085,8 @@ reuse_rx:
                        }
                }
 
+               // AKAROS_PORT TODO: set hash and checksum stuff
+#if 0
                skb_put(skb, len);
                skb->protocol = eth_type_trans(skb, bp->dev);
 
@@ -1104,6 +1113,8 @@ reuse_rx:
                        netif_receive_skb(skb);
                else
                        napi_gro_receive(&fp->napi, skb);
+#endif
+               etheriq(bp->edev, block, TRUE);
 next_rx:
                rx_buf->data = NULL;
 
@@ -1111,7 +1122,6 @@ next_rx:
                bd_prod = NEXT_RX_IDX(bd_prod);
                bd_prod_fw = NEXT_RX_IDX(bd_prod_fw);
                rx_pkt++;
-#endif
 next_cqe:
                sw_comp_prod = NEXT_RCQ_IDX(sw_comp_prod);
                sw_comp_cons = NEXT_RCQ_IDX(sw_comp_cons);
index e414149..730b628 100644 (file)
@@ -33,6 +33,7 @@ extern int bnx2x_init_one(struct ether *dev, struct bnx2x *bp,
                           struct pci_device *pdev,
                           const struct pci_device_id *ent);
 extern int bnx2x_open(struct ether *dev);
+extern void bnx2x_set_rx_mode(struct ether *dev);
 
 spinlock_t bnx2x_tq_lock = SPINLOCK_INITIALIZER;
 TAILQ_HEAD(bnx2x_tq, bnx2x);
@@ -268,8 +269,7 @@ static void bnx2x_attach(struct ether *edev)
        }
 
        bnx2x_open(ctlr->edev);
-
-       //do this next: ndo_set_rx_mode
+       bnx2x_set_rx_mode(edev);
 
        /* shut it up for now.  too much stats output */
        ctlr->msg_enable = 0;
index 768882b..18c14a4 100644 (file)
@@ -12498,7 +12498,7 @@ panic("Not implemented");
 }
 
 /* If bp->state is OPEN, should be called with netif_addr_lock_bh() */
-static void bnx2x_set_rx_mode(struct ether *dev)
+void bnx2x_set_rx_mode(struct ether *dev)
 {
        struct bnx2x *bp = netdev_priv(dev);