aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEugenia Emantayev <eugenia@mellanox.co.il>2011-12-12 23:16:38 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-13 13:56:07 -0500
commit5b4c4d36860ef1c411d0669ffc15090417a33389 (patch)
treeabd1a09a1f97cf41bc2e08c6bd505f3a632b393c /drivers
parentffe455ad04681f3fc48eef595fe526a795f809a3 (diff)
mlx4_en: Allow communication between functions on same host
To enable internal loopback, always fill DMAC in control segment when transmitting the packet, once this is done, the packet is subject for loopback for if the DMAC mathces one of the multicast/unicast addresses registered on the physical port. In receive path if source MAC is our own MAC and we are not in selftest, or not in force LB mode - drop this packet. Signed-off-by: Eugenia Emantayev <eugenia@mellanox.co.il> Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c20
2 files changed, 24 insertions, 11 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index ce1bc573d11..630a7c113ab 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -541,6 +541,8 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
541 unsigned int length; 541 unsigned int length;
542 int polled = 0; 542 int polled = 0;
543 int ip_summed; 543 int ip_summed;
544 struct ethhdr *ethh;
545 u64 s_mac;
544 546
545 if (!priv->port_up) 547 if (!priv->port_up)
546 return 0; 548 return 0;
@@ -577,6 +579,19 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
577 goto next; 579 goto next;
578 } 580 }
579 581
582 /* Get pointer to first fragment since we haven't skb yet and
583 * cast it to ethhdr struct */
584 ethh = (struct ethhdr *)(page_address(skb_frags[0].page) +
585 skb_frags[0].offset);
586 s_mac = mlx4_en_mac_to_u64(ethh->h_source);
587
588 /* If source MAC is equal to our own MAC and not performing
589 * the selftest or flb disabled - drop the packet */
590 if (s_mac == priv->mac &&
591 (!(dev->features & NETIF_F_LOOPBACK) ||
592 !priv->validate_loopback))
593 goto next;
594
580 /* 595 /*
581 * Packet is OK - process it. 596 * Packet is OK - process it.
582 */ 597 */
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 7e76862de35..9ef9038d062 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -688,17 +688,15 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
688 ring->tx_csum++; 688 ring->tx_csum++;
689 } 689 }
690 690
691 if (unlikely(priv->validate_loopback)) { 691 /* Copy dst mac address to wqe */
692 /* Copy dst mac address to wqe */ 692 skb_reset_mac_header(skb);
693 skb_reset_mac_header(skb); 693 ethh = eth_hdr(skb);
694 ethh = eth_hdr(skb); 694 if (ethh && ethh->h_dest) {
695 if (ethh && ethh->h_dest) { 695 mac = mlx4_en_mac_to_u64(ethh->h_dest);
696 mac = mlx4_en_mac_to_u64(ethh->h_dest); 696 mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16);
697 mac_h = (u32) ((mac & 0xffff00000000ULL) >> 16); 697 mac_l = (u32) (mac & 0xffffffff);
698 mac_l = (u32) (mac & 0xffffffff); 698 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h);
699 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(mac_h); 699 tx_desc->ctrl.imm = cpu_to_be32(mac_l);
700 tx_desc->ctrl.imm = cpu_to_be32(mac_l);
701 }
702 } 700 }
703 701
704 /* Handle LSO (TSO) packets */ 702 /* Handle LSO (TSO) packets */