Skip to contentSkip to conversation

bnx2x: set Ethernet address type during transmit for VF's

PATCH Applied Chas Williams 4 participants 9 messages Nov 18, 2015 – Dec 8, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bnx2x: set Ethernet address type during transmit for VF's

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
 drivers/net/bnx2x/bnx2x.c     | 23 +++++++++++++++--------
 drivers/net/bnx2x/ecore_hsi.h |  5 +++--
 2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +15 -8
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_p
 		bd_prod = NEXT_TX_BD(bd_prod);
 		if (IS_VF(sc)) {
 			struct eth_tx_parse_bd_e2 *tx_parse_bd;
-			uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+			const struct ether_hdr *eh = rte_pktmbuf_mtod(m0, struct ether_hdr *);
+			uint8_t mac_type = UNICAST_ADDRESS;
 
 			tx_parse_bd =
 			    &txq->tx_ring[TX_BD(bd_prod, txq)].parse_bd_e2;
+			if (is_multicast_ether_addr(&eh->d_addr)) {
+				if (is_broadcast_ether_addr(&eh->d_addr))
+					mac_type = BROADCAST_ADDRESS;
+				else
+					mac_type = MULTICAST_ADDRESS;
+			}
 			tx_parse_bd->parsing_data =
-			    (1 << ETH_TX_PARSE_BD_E2_ETH_ADDR_TYPE_SHIFT);
+			    (mac_type << ETH_TX_PARSE_BD_E2_ETH_ADDR_TYPE_SHIFT);
 
 			rte_memcpy(&tx_parse_bd->data.mac_addr.dst_hi,
-				   &data[0], 2);
+				   &eh->d_addr.addr_bytes[0], 2);
 			rte_memcpy(&tx_parse_bd->data.mac_addr.dst_mid,
-				   &data[2], 2);
+				   &eh->d_addr.addr_bytes[2], 2);
 			rte_memcpy(&tx_parse_bd->data.mac_addr.dst_lo,
-				   &data[4], 2);
+				   &eh->d_addr.addr_bytes[4], 2);
 			rte_memcpy(&tx_parse_bd->data.mac_addr.src_hi,
-				   &data[6], 2);
+				   &eh->s_addr.addr_bytes[0], 2);
 			rte_memcpy(&tx_parse_bd->data.mac_addr.src_mid,
-				   &data[8], 2);
+				   &eh->s_addr.addr_bytes[2], 2);
 			rte_memcpy(&tx_parse_bd->data.mac_addr.src_lo,
-				   &data[10], 2);
+				   &eh->s_addr.addr_bytes[4], 2);
 
 			tx_parse_bd->data.mac_addr.dst_hi =
 			    rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.dst_hi);
drivers/net/bnx2x/ecore_hsi.h +3 -2
index a4ed9b5..6c11c5a 100644
@@ -4029,7 +4029,7 @@ struct double_regpair
 
 
 /*
- * Ethernet address typesm used in ethernet tx BDs
+ * Ethernet address types used in ethernet tx BDs
  */
 enum eth_addr_type
 {
@@ -4037,7 +4037,8 @@ enum eth_addr_type
 	UNICAST_ADDRESS,
 	MULTICAST_ADDRESS,
 	BROADCAST_ADDRESS,
-	MAX_ETH_ADDR_TYPE};
+	MAX_ETH_ADDR_TYPE
+};
 
 
 /*
Signature · 1 line
2.1.0
#1 lore raw

2015-11-18 15:58, Chas Williams:

Quoted 4 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

Applied, thanks

#2 lore raw

2015-12-06 23:20, Thomas Monjalon:

Quoted 7 lines

2015-11-18 15:58, Chas Williams:

Quoted 4 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

Applied, thanks

No sorry, not applied, it needs review.

Acked-by on v1 1/1
#3 lore raw
In reply to Chas Williams
Quoted 19 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq,

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;

drivers/net/bnx2x/bnx2x.c int bnx2x_tx_encap(struct bnx2x_tx_queue *txq, struct rte_mbuf **m_head, int m_p · line 2185

Quoted 7 lines
drivers/net/bnx2x/bnx2x.c +3 -1
-                      uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+                      const struct ether_hdr *eh = rte_pktmbuf_mtod(m0, struct ether_hdr *);
+                      uint8_t mac_type = UNICAST_ADDRESS;
 
                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod, txq)].parse_bd_e2;
+                      if (is_multicast_ether_addr(&eh->d_addr)) {

Minor comment. unlikely() may be used here to keep it consistent with base driver.

Quoted 54 lines
drivers/net/bnx2x/bnx2x.c +12 -7
+                              if (is_broadcast_ether_addr(&eh->d_addr))
+                                      mac_type = BROADCAST_ADDRESS;
+                              else
+                                      mac_type = MULTICAST_ADDRESS;
+                      }
                      tx_parse_bd->parsing_data =
-                          (1 << ETH_TX_PARSE_BD_E2_ETH_ADDR_TYPE_SHIFT);
+                          (mac_type << ETH_TX_PARSE_BD_E2_ETH_ADDR_TYPE_SHIFT);
 
                      rte_memcpy(&tx_parse_bd->data.mac_addr.dst_hi,
-                                 &data[0], 2);
+                                 &eh->d_addr.addr_bytes[0], 2);
                      rte_memcpy(&tx_parse_bd->data.mac_addr.dst_mid,
-                                 &data[2], 2);
+                                 &eh->d_addr.addr_bytes[2], 2);
                      rte_memcpy(&tx_parse_bd->data.mac_addr.dst_lo,
-                                 &data[4], 2);
+                                 &eh->d_addr.addr_bytes[4], 2);
                      rte_memcpy(&tx_parse_bd->data.mac_addr.src_hi,
-                                 &data[6], 2);
+                                 &eh->s_addr.addr_bytes[0], 2);
                      rte_memcpy(&tx_parse_bd->data.mac_addr.src_mid,
-                                 &data[8], 2);
+                                 &eh->s_addr.addr_bytes[2], 2);
                      rte_memcpy(&tx_parse_bd->data.mac_addr.src_lo,
-                                 &data[10], 2);
+                                 &eh->s_addr.addr_bytes[4], 2);
 
                      tx_parse_bd->data.mac_addr.dst_hi =
                          rte_cpu_to_be_16(tx_parse_bd->data.mac_addr.dst_hi);
drivers/net/bnx2x/ecore_hsi.h +1 -1
index a4ed9b5..6c11c5a 100644
@@ -4029,7 +4029,7 @@ struct double_regpair
 
 
 /*
- * Ethernet address typesm used in ethernet tx BDs
+ * Ethernet address types used in ethernet tx BDs
 */

enum eth_addr_type
{

drivers/net/bnx2x/ecore_hsi.h +2 -2
@@ -4037,7 +4037,8 @@ enum eth_addr_type
      UNICAST_ADDRESS,
      MULTICAST_ADDRESS,
      BROADCAST_ADDRESS,
-      MAX_ETH_ADDR_TYPE};
+      MAX_ETH_ADDR_TYPE
+};
 
 
 /*
--
Quoted 3 lines

2.1.0

Thanks,
Harish

________________________________

This message and any attached documents contain information from the sending company or its parent company(s), subsidiaries, divisions or branch offices that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.

#4 lore raw
Quoted 23 lines · Harish Patil
Quoted 23 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq,

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;
drivers/net/bnx2x/bnx2x.c +2 -1
-                      uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+                      const struct ether_hdr *eh = rte_pktmbuf_mtod(m0, struct ether_hdr *);
+                      uint8_t mac_type = UNICAST_ADDRESS;
Quoted 6 lines
Quoted 3 lines
                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod, txq)].parse_bd_e2;

+ if (is_multicast_ether_addr(&eh->d_addr)) {

Minor comment. unlikely() may be used here to keep it consistent with base driver.

It wasn't clear to me that this code path is all that unlikely().

Quoted 5 lines
Quoted 5 lines
drivers/net/bnx2x/bnx2x.c +5 -0
+                              if (is_broadcast_ether_addr(&eh->d_addr))
+                                      mac_type = BROADCAST_ADDRESS;
+                              else
+                                      mac_type = MULTICAST_ADDRESS;
+                      }
#5 lore raw
Quoted 28 lines · Harish Patil
Quoted 26 lines
Quoted 19 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq,

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;

drivers/net/bnx2x/bnx2x.c

Quoted 2 lines
drivers/net/bnx2x/bnx2x.c +1 -1
-                      uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+                      const struct ether_hdr *eh =

rte_pktmbuf_mtod(m0, struct ether_hdr *);

Quoted 4 lines

+ uint8_t mac_type = UNICAST_ADDRESS;

                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod,
Quoted 8 lines
Quoted 6 lines

txq)].parse_bd_e2;

Quoted 1 line

+ if (is_multicast_ether_addr(&eh->d_addr)) {

Minor comment. unlikely() may be used here to keep it consistent with base
driver.

It wasn't clear to me that this code path is all that unlikely().

Its an optional comment, unlikely() is because fast path traffic is mostly unicast.
BTW, have you tested the patches? Another question, not related to your change though.
I guess this block of code does not have to been under the IS_VF() check.

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

+ if

(is_broadcast_ether_addr(&eh->d_addr))

Quoted 4 lines
drivers/net/bnx2x/bnx2x.c +4 -0
+                                      mac_type = BROADCAST_ADDRESS;
+                              else
+                                      mac_type = MULTICAST_ADDRESS;
+                      }

________________________________

This message and any attached documents contain information from the sending company or its parent company(s), subsidiaries, divisions or branch offices that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.

#6 lore raw
Quoted 31 lines · Harish Patil
Quoted 31 lines · Harish Patil
Quoted 29 lines
Quoted 19 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq,

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;

drivers/net/bnx2x/bnx2x.c

Quoted 2 lines
drivers/net/bnx2x/bnx2x.c +1 -1
-                      uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+                      const struct ether_hdr *eh =

rte_pktmbuf_mtod(m0, struct ether_hdr *);

Quoted 4 lines

+ uint8_t mac_type = UNICAST_ADDRESS;

                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod,

txq)].parse_bd_e2;

Quoted 1 line

+ if (is_multicast_ether_addr(&eh->d_addr)) {

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Minor comment. unlikely() may be used here to keep it consistent with base
driver.

It wasn't clear to me that this code path is all that unlikely().

Its an optional comment, unlikely() is because fast path traffic is mostly unicast.

Multicast traffic isn't all that uncommon. I also don't see that we gain much from branch prediction here regardless. My understanding is that unlikely() should be used for really unlikely situations since the branch will not be optimized.

Quoted 2 lines

BTW, have you tested the patches? Another question, not related to your change though.

Yes. This patch is necessary (for VF anyway). Without it, you need to manually assign arp addresses.

Quoted 1 line

I guess this block of code does not have to been under the IS_VF() check.

I don't know. It is under IS_VF() in the linux driver and it looks like an attempt to "program" some internal switch on the card. I don't have a programmer's guide for this card so it's a complete guess.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

+ if

(is_broadcast_ether_addr(&eh->d_addr))

Quoted 4 lines
drivers/net/bnx2x/bnx2x.c +4 -0
+                                      mac_type = BROADCAST_ADDRESS;
+                              else
+                                      mac_type = MULTICAST_ADDRESS;
+                      }
#7 lore raw
Quoted 38 lines · Charles (Chas) Williams
Quoted 37 lines · Harish Patil
Quoted 36 lines · Harish Patil
Quoted 24 lines
Quoted 19 lines

The original was always setting unicast. While here, clean up some other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue *txq,

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;

drivers/net/bnx2x/bnx2x.c

Quoted 2 lines
drivers/net/bnx2x/bnx2x.c +1 -1
-                      uint8_t *data = rte_pktmbuf_mtod(m0, uint8_t *);
+                      const struct ether_hdr *eh =

rte_pktmbuf_mtod(m0, struct ether_hdr *);

Quoted 2 lines

+ uint8_t mac_type = UNICAST_ADDRESS;

Quoted 8 lines
Quoted 2 lines
                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod,

txq)].parse_bd_e2;

Quoted 1 line

+ if (is_multicast_ether_addr(&eh->d_addr)) {

Minor comment. unlikely() may be used here to keep it consistent with base
driver.

It wasn't clear to me that this code path is all that unlikely().

Quoted 7 lines
Quoted 2 lines

Its an optional comment, unlikely() is because fast path traffic is mostly unicast.

Multicast traffic isn't all that uncommon. I also don't see that we gain much from branch prediction here regardless. My understanding is that unlikely() should be used for really unlikely situations since the branch will not be optimized.

+1 to this.

Let the cpu branch predictor do the work at run-time picking the correct leg of the branch. likely()/unlikely() should only ever be used for things like fatal error conditions where it doesn't matter how optimized the unlikely branch part is. For normal code where there is no error, don't try and optimize it using likely()/unlikely() unless you can prove there is a definite performance improvement by doing so.

/Bruce

#8 lore raw
Quoted 68 lines · Charles (Chas) Williams
Quoted 44 lines · Harish Patil
Quoted 4 lines
Quoted 4 lines · Harish Patil
Quoted 2 lines
Quoted 2 lines

The original was always setting unicast. While here, clean up

some

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

other references that also point into the Ethernet header.

---
drivers/net/bnx2x/bnx2x.c | 23 +++++++++++++++--------
drivers/net/bnx2x/ecore_hsi.h | 5 +++--

2 files changed, 18 insertions(+), 10 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/net/bnx2x/bnx2x.c int bnx2x_tx_encap(struct bnx2x_tx_queue

Quoted 5 lines
drivers/net/bnx2x/bnx2x.c +0 -0
index 76444eb..294711f 100644
@@ -2177,25 +2177,32 @@ int bnx2x_tx_encap(struct bnx2x_tx_queue

*txq,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

struct rte_mbuf **m_head, int m_p

              bd_prod = NEXT_TX_BD(bd_prod);
              if (IS_VF(sc)) {
                      struct eth_tx_parse_bd_e2 *tx_parse_bd;

- uint8_t *data = rte_pktmbuf_mtod(m0,

uint8_t *);

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 1 line

+ const struct ether_hdr *eh =

rte_pktmbuf_mtod(m0, struct ether_hdr *);

Quoted 4 lines

+ uint8_t mac_type = UNICAST_ADDRESS;

                      tx_parse_bd =
                          &txq->tx_ring[TX_BD(bd_prod,

txq)].parse_bd_e2;

Quoted 1 line

+ if (is_multicast_ether_addr(&eh->d_addr)) {

Minor comment. unlikely() may be used here to keep it consistent

with

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

base
driver.

It wasn't clear to me that this code path is all that unlikely().

Its an optional comment, unlikely() is because fast path traffic is

mostly

Quoted 8 lines
Quoted 1 line

unicast.

Multicast traffic isn't all that uncommon. I also don't see that we gain
much from branch prediction here regardless. My understanding is that unlikely() should be used for really unlikely situations since the branch
will not be optimized.

+1 to this.

Let the cpu branch predictor do the work at run-time picking the correct leg of the branch. likely()/unlikely() should only ever be used for
things like fatal error conditions where it doesn't matter how optimized the
unlikely branch part is. For normal code where there is no error, don't try and
optimize it using likely()/unlikely() unless you can prove there is a definite
performance improvement by doing so.

Quoted 2 lines

/Bruce

I agree too, lets leave it that way. As I said its optional, to be same as linux base driver which has:
3809 /* set flag according to packet type (UNICAST_ADDRESS is
default)*/
3810 if (unlikely(is_multicast_ether_addr(eth->h_dest))) {

Thanks,
Harish

________________________________

This message and any attached documents contain information from the sending company or its parent company(s), subsidiaries, divisions or branch offices that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.