Skip to contentSkip to conversation

net/mlx4_en: adding loopback support

PATCH Superseded Yevgeny Petrilin 3 participants 3 messages Nov 21, 2011 – Nov 23, 2011

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 7/8 net/mlx4_en: adding loopback support

From: Amir Vadai <[email protected]>

Device must be in promiscious mode or DMAC must be same as the host MAC, or else packet will be dropped by the HW rx filtering.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    1 +
 drivers/net/ethernet/mellanox/mlx4/en_tx.c     |    3 +++
 include/linux/mlx4/qp.h                        |    1 +
 3 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +1 -0
index 78d776b..55fdbce 100644
@@ -1088,6 +1088,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
 	dev->features = dev->hw_features | NETIF_F_HIGHDMA |
 			NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX |
 			NETIF_F_HW_VLAN_FILTER;
+	dev->hw_features |= NETIF_F_LOOPBACK;
 
 	mdev->pndev[port] = dev;
 
drivers/net/ethernet/mellanox/mlx4/en_tx.c +3 -0
index 3094f94..f9093b5 100644
@@ -681,6 +681,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
 	tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f;
 	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 						MLX4_WQE_CTRL_SOLICITED);
+	if (dev->features & NETIF_F_LOOPBACK)
+		tx_desc->ctrl.srcrb_flags |=
+			cpu_to_be32(MLX4_WQE_CTRL_FORCE_LOOPBACK);
 	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
 		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
include/linux/mlx4/qp.h +1 -0
index 6562ff6..bee8fa2 100644
@@ -210,6 +210,7 @@ struct mlx4_wqe_ctrl_seg {
 	 * [4]   IP checksum
 	 * [3:2] C (generate completion queue entry)
 	 * [1]   SE (solicited event)
+	 * [0]   FL (force loopback)
 	 */
 	__be32			srcrb_flags;
 	/*
Signature · 1 line
1.7.7
#1 lore raw
Quoted 31 lines · Yevgeny Petrilin

From: Amir Vadai <[email protected]>

Device must be in promiscious mode or DMAC must be same as the host MAC, or else packet will be dropped by the HW rx filtering.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    1 + drivers/net/ethernet/mellanox/mlx4/en_tx.c     |    3 +++ include/linux/mlx4/qp.h                        |    1 +

 3 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
index 78d776b..55fdbce 100644
@@ -1088,6 +1088,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,

       dev->features = dev->hw_features | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
+       dev->hw_features |= NETIF_F_LOOPBACK;

       mdev->pndev[port] = dev;

drivers/net/ethernet/mellanox/mlx4/en_tx.c +0 -0
index 3094f94..f9093b5 100644
@@ -681,6 +681,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
        tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f;
Quoted 5 lines

       tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE | MLX4_WQE_CTRL_SOLICITED);
+       if (dev->features & NETIF_F_LOOPBACK)
+               tx_desc->ctrl.srcrb_flags |=
+                       cpu_to_be32(MLX4_WQE_CTRL_FORCE_LOOPBACK);

This is re-calculated for every xmit. Is it required to be that way? May be you can pre-calculate it and just assign / add it to the control-flags here.

Quoted 25 lines

       if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM);

include/linux/mlx4/qp.h +1 -1
index 6562ff6..bee8fa2 100644
@@ -210,6 +210,7 @@ struct mlx4_wqe_ctrl_seg {
         * [4]   IP checksum
         * [3:2] C (generate completion queue entry)
         * [1]   SE (solicited event)
+        * [0]   FL (force loopback)
         */
        __be32                  srcrb_flags;
        /*
--

1.7.7

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw

Yes, this is a good idea. I will fix it.

- Amir

-----Original Message-----
From: Mahesh Bandewar [mailto:[email protected]]
Sent: Wednesday, November 23, 2011 3:35 AM
To: Yevgeny Petrilin
Cc: [email protected]; [email protected]; Or Gerlitz; Oren Duer; Amir Vadai
Subject: Re: [PATCH 7/8] net/mlx4_en: adding loopback support

Quoted 31 lines · Yevgeny Petrilin

From: Amir Vadai <[email protected]>

Device must be in promiscious mode or DMAC must be same as the host MAC, or else packet will be dropped by the HW rx filtering.

---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    1 + drivers/net/ethernet/mellanox/mlx4/en_tx.c     |    3 +++ include/linux/mlx4/qp.h                        |    1 +

 3 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +0 -0
index 78d776b..55fdbce 100644
@@ -1088,6 +1088,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,

       dev->features = dev->hw_features | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
+       dev->hw_features |= NETIF_F_LOOPBACK;

       mdev->pndev[port] = dev;

drivers/net/ethernet/mellanox/mlx4/en_tx.c +0 -0
index 3094f94..f9093b5 100644
@@ -681,6 +681,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
        tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f;
Quoted 5 lines

       tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE | MLX4_WQE_CTRL_SOLICITED);
+       if (dev->features & NETIF_F_LOOPBACK)
+               tx_desc->ctrl.srcrb_flags |=
+                       cpu_to_be32(MLX4_WQE_CTRL_FORCE_LOOPBACK);

This is re-calculated for every xmit. Is it required to be that way? May be you can pre-calculate it and just assign / add it to the control-flags here.

Quoted 25 lines

       if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | MLX4_WQE_CTRL_TCP_UDP_CSUM);

include/linux/mlx4/qp.h +1 -1
index 6562ff6..bee8fa2 100644
@@ -210,6 +210,7 @@ struct mlx4_wqe_ctrl_seg {
         * [4]   IP checksum
         * [3:2] C (generate completion queue entry)
         * [1]   SE (solicited event)
+        * [0]   FL (force loopback)
         */
        __be32                  srcrb_flags;
        /*
--

1.7.7

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html