Skip to contentSkip to conversation

net/axgbe: add additional MAC address support

PATCH New [email protected] 1 participant 2 messages Feb 28, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net/axgbe: add additional MAC address support

From: Chandu Babu N <[email protected]>

Supports adding MAC addresses to enable whitelist filtering to accept packets
implement eth_dev_ops mac_addr_set, mac_addr_add, mac_addr_remove and set_mc_addr_list

---
 drivers/net/axgbe/axgbe_dev.c    | 29 ++++++++++
 drivers/net/axgbe/axgbe_ethdev.c | 94 ++++++++++++++++++++++++++++++--
 drivers/net/axgbe/axgbe_ethdev.h |  4 +-
 3 files changed, 121 insertions(+), 6 deletions(-)
drivers/net/axgbe/axgbe_dev.c +29 -0
index 2e796c0b3..f830b7230 100644
@@ -1008,6 +1008,35 @@ static void axgbe_enable_mtl_interrupts(struct axgbe_port *pdata)
 	}
 }
 
+void axgbe_set_mac_addn_addr(struct axgbe_port *pdata, u8 *addr, uint32_t index)
+{
+	unsigned int mac_addr_hi, mac_addr_lo;
+	u8 *mac_addr;
+
+	mac_addr_lo = 0;
+	mac_addr_hi = 0;
+
+	if (addr) {
+		mac_addr = (u8 *)&mac_addr_lo;
+		mac_addr[0] = addr[0];
+		mac_addr[1] = addr[1];
+		mac_addr[2] = addr[2];
+		mac_addr[3] = addr[3];
+		mac_addr = (u8 *)&mac_addr_hi;
+		mac_addr[0] = addr[4];
+		mac_addr[1] = addr[5];
+
+		/*Address Enable: Use this Addr for Perfect Filtering */
+		AXGMAC_SET_BITS(mac_addr_hi, MAC_MACA1HR, AE, 1);
+	}
+
+	PMD_DRV_LOG(DEBUG, "%s mac address at %#x\n",
+		    addr ? "set" : "clear", index);
+
+	AXGMAC_IOWRITE(pdata, MAC_MACAHR(index), mac_addr_hi);
+	AXGMAC_IOWRITE(pdata, MAC_MACALR(index), mac_addr_lo);
+}
+
 static int axgbe_set_mac_address(struct axgbe_port *pdata, u8 *addr)
 {
 	unsigned int mac_addr_hi, mac_addr_lo;
drivers/net/axgbe/axgbe_ethdev.c +89 -5

132 lines not on this page · raw message

drivers/net/axgbe/axgbe_ethdev.h +3 -1
index a1083b17b..781d170e5 100644
@@ -16,7 +16,7 @@
 #define AXGBE_TX_MAX_BUF_SIZE		(0x3fff & ~(64 - 1))
 #define AXGBE_RX_MAX_BUF_SIZE		(0x3fff & ~(64 - 1))
 #define AXGBE_RX_MIN_BUF_SIZE		(RTE_ETHER_MAX_LEN + VLAN_HLEN)
-#define AXGBE_MAX_MAC_ADDRS		1
+#define AXGBE_MAX_MAC_ADDRS		32
 
 #define AXGBE_RX_BUF_ALIGN		64
 
@@ -631,5 +631,7 @@ void axgbe_init_function_ptrs_dev(struct axgbe_hw_if *hw_if);
 void axgbe_init_function_ptrs_phy(struct axgbe_phy_if *phy_if);
 void axgbe_init_function_ptrs_phy_v2(struct axgbe_phy_if *phy_if);
 void axgbe_init_function_ptrs_i2c(struct axgbe_i2c_if *i2c_if);
+void axgbe_set_mac_addn_addr(struct axgbe_port *pdata, u8 *addr,
+			     uint32_t index);
 
 #endif /* RTE_ETH_AXGBE_H_ */
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 net/axgbe: add unicast hash table for mac address

From: Chandu Babu N <[email protected]>

implement eth_dev_ops uc_hash_table_set and uc_all_hash_table_set

---
 drivers/net/axgbe/axgbe_common.h |  2 +
 drivers/net/axgbe/axgbe_dev.c    | 60 ++++++++++++++++++++++++
 drivers/net/axgbe/axgbe_ethdev.c | 79 ++++++++++++++++++++++++++++++++
 drivers/net/axgbe/axgbe_ethdev.h | 10 +++-
 4 files changed, 150 insertions(+), 1 deletion(-)
drivers/net/axgbe/axgbe_common.h +2 -0
index 2ac4d8946..72683aa65 100644
@@ -292,6 +292,8 @@
 #define MAC_MACAHR(i)	(MAC_MACA0HR + ((i) * 8))
 #define MAC_MACALR(i)	(MAC_MACA0LR + ((i) * 8))
 
+#define MAC_HTR(i)	(MAC_HTR0 + ((i) * MAC_HTR_INC))
+
 /* MAC register entry bit positions and sizes */
 #define MAC_HWF0R_ADDMACADRSEL_INDEX	18
 #define MAC_HWF0R_ADDMACADRSEL_WIDTH	5
drivers/net/axgbe/axgbe_dev.c +60 -0

78 lines not on this page · raw message

drivers/net/axgbe/axgbe_ethdev.c +79 -0

109 lines not on this page · raw message

drivers/net/axgbe/axgbe_ethdev.h +9 -1
index 781d170e5..3969317fd 100644
@@ -17,6 +17,7 @@
 #define AXGBE_RX_MAX_BUF_SIZE		(0x3fff & ~(64 - 1))
 #define AXGBE_RX_MIN_BUF_SIZE		(RTE_ETHER_MAX_LEN + VLAN_HLEN)
 #define AXGBE_MAX_MAC_ADDRS		32
+#define AXGBE_MAX_HASH_MAC_ADDRS	256
 
 #define AXGBE_RX_BUF_ALIGN		64
 
@@ -83,7 +84,7 @@
 	(((_x) < 1024) ? 0 : ((_x) / AXGMAC_FLOW_CONTROL_UNIT) - 2)
 #define AXGMAC_FLOW_CONTROL_MAX		33280
 
-/* Maximum MAC address hash table size (256 bits = 8 bytes) */
+/* Maximum MAC address hash table size (256 bits = 8 dword) */
 #define AXGBE_MAC_HASH_TABLE_SIZE	8
 
 /* Receive Side Scaling */
@@ -625,6 +626,12 @@ struct axgbe_port {
 	uint32_t rx_csum_enable;
 
 	struct axgbe_mmc_stats mmc_stats;
+
+	/* Hash filtering */
+	unsigned int hash_table_shift;
+	unsigned int hash_table_count;
+	unsigned int uc_hash_mac_addr;
+	unsigned int uc_hash_table[AXGBE_MAC_HASH_TABLE_SIZE];
 };
 
 void axgbe_init_function_ptrs_dev(struct axgbe_hw_if *hw_if);
@@ -633,5 +640,6 @@ void axgbe_init_function_ptrs_phy_v2(struct axgbe_phy_if *phy_if);
 void axgbe_init_function_ptrs_i2c(struct axgbe_i2c_if *i2c_if);
 void axgbe_set_mac_addn_addr(struct axgbe_port *pdata, u8 *addr,
 			     uint32_t index);
+void axgbe_set_mac_hash_table(struct axgbe_port *pdata, u8 *addr, bool add);
 
 #endif /* RTE_ETH_AXGBE_H_ */
Signature · 1 line
2.17.1