Skip to contentSkip to conversation

i40e: Add macvlan support on i40e

PATCH Superseded Harshitha Ramamurthy 3 participants 3 messages Mar 13, 2019 – Mar 14, 2019

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 i40e: Add macvlan support on i40e

This patch enables macvlan offloads for i40e. The idea is to use channels as macvlan interfaces. The channels are VSIs of type VMDQ. When the first macvlan is created, the maximum number of channels possible are created. From then on, as a macvlan interface is created, a mac filter is added to these already created channels (VSIs).

This patch builds on top of the recent changes which move away from the select_queue implementation of picking the tx queue.

Steps to configure macvlan offloads:
1. sudo ethtool -K ens261f1 l2-fwd-offload on
2. ip link add link ens261f1 name macvlan1 type macvlan
3. sudo ip link add link ens261f1 name macvlan1 type macvlan
4. sudo ip link set macvlan1 up

---
v4: Added code to check for a non-empty list of macvlans before deleting them

v3: Renamed i40e_remove_macvlan_channels() to i40e_free_macvlan_channels()
Fixed an indentation issue and added some comments
Removed a code name from the commit message
Addressed some more of Shannon's comments

v2: Addressed Shannon's comments
Added a new function to remove all macvlan VSIs

 drivers/net/ethernet/intel/i40e/i40e.h      |  26 ++
 drivers/net/ethernet/intel/i40e/i40e_main.c | 484 +++++++++++++++++++-
 2 files changed, 508 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +26 -0
index c4afb852cb57..c44f9f7acbb5 100644
@@ -27,6 +27,7 @@
 #include <net/ip6_checksum.h>
 #include <linux/ethtool.h>
 #include <linux/if_vlan.h>
+#include <linux/if_macvlan.h>
 #include <linux/if_bridge.h>
 #include <linux/clocksource.h>
 #include <linux/net_tstamp.h>
@@ -413,6 +414,11 @@ struct i40e_flex_pit {
 	u8 pit_index;
 };
 
+struct i40e_fwd_adapter {
+	struct net_device *netdev;
+	int bit_no;
+};
+
 struct i40e_channel {
 	struct list_head list;
 	bool initialized;
@@ -427,11 +433,25 @@ struct i40e_channel {
 	struct i40e_aqc_vsi_properties_data info;
 
 	u64 max_tx_rate;
+	struct i40e_fwd_adapter *fwd;
 
 	/* track this channel belongs to which VSI */
 	struct i40e_vsi *parent_vsi;
 };
 
+static inline bool i40e_is_channel_macvlan(struct i40e_channel *ch)
+{
+	return !!ch->fwd;
+}
+
+static inline u8 *i40e_channel_mac(struct i40e_channel *ch)
+{
+	if (i40e_is_channel_macvlan(ch))
+		return ch->fwd->netdev->dev_addr;
+	else
+		return NULL;
+}
+
 /* struct that defines the Ethernet device */
 struct i40e_pf {
 	struct pci_dev *pdev;
@@ -813,6 +833,12 @@ struct i40e_vsi {
 	struct list_head ch_list;
 	u16 tc_seid_map[I40E_MAX_TRAFFIC_CLASS];
 
+	/* macvlan fields */
+#define I40E_MAX_MACVLANS	128 /* Max HW capable vectors - 1 on FVL */
+	DECLARE_BITMAP(fwd_bitmask, I40E_MAX_MACVLANS);
+	struct list_head macvlan_list;
+	int macvlan_cnt;
+
 	void *priv;	/* client driver data reference. */
 
 	/* VSI specific handlers */
drivers/net/ethernet/intel/i40e/i40e_main.c +482 -2

514 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/1 i40e: Add macvlan support on i40e

Quoted 32 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Harshitha Ramamurthy
Sent: Wednesday, March 13, 2019 10:03 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH v4] i40e: Add macvlan support on i40e

This patch enables macvlan offloads for i40e. The idea is to use channels as macvlan interfaces. The channels are VSIs of type VMDQ. When the first macvlan is created, the maximum number of channels possible are created. From then on, as a macvlan interface is created, a mac filter is added to these already created channels (VSIs).

This patch builds on top of the recent changes which move away from the select_queue implementation of picking the tx queue.

Steps to configure macvlan offloads:
1. sudo ethtool -K ens261f1 l2-fwd-offload on
2. ip link add link ens261f1 name macvlan1 type macvlan
3. sudo ip link add link ens261f1 name macvlan1 type macvlan
4. sudo ip link set macvlan1 up

---
v4: Added code to check for a non-empty list of macvlans before deleting them

v3: Renamed i40e_remove_macvlan_channels() to i40e_free_macvlan_channels()
Fixed an indentation issue and added some comments Removed a code name from the commit message Addressed some more of Shannon's comments

Quoted 7 lines

v2: Addressed Shannon's comments
Added a new function to remove all macvlan VSIs

 drivers/net/ethernet/intel/i40e/i40e.h      |  26 ++
 drivers/net/ethernet/intel/i40e/i40e_main.c | 484 +++++++++++++++++++-
 2 files changed, 508 insertions(+), 2 deletions(-)

Step 2 and 3 in the example to configure macvlans are the same except for the use of sudo (which I suspect Jeff can fix up without another spin.) Aside from that:

#2 lore raw

PATCH v4 1/1 i40e: Add macvlan support on i40e

I was just noticing the same thing about the example steps. You might also want to add an "add address" command in there before the "set up" command.
sln

Quoted 48 lines · Aaron F
Quoted 33 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Harshitha Ramamurthy
Sent: Wednesday, March 13, 2019 10:03 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH v4] i40e: Add macvlan support on i40e

This patch enables macvlan offloads for i40e. The idea is to use channels as macvlan interfaces. The channels are VSIs of type VMDQ. When the first macvlan is created, the maximum number of channels possible are created. From then on, as a macvlan interface is created, a mac filter is added to these already created channels (VSIs).

This patch builds on top of the recent changes which move away from the select_queue implementation of picking the tx queue.

Steps to configure macvlan offloads:
1. sudo ethtool -K ens261f1 l2-fwd-offload on
2. ip link add link ens261f1 name macvlan1 type macvlan
3. sudo ip link add link ens261f1 name macvlan1 type macvlan
4. sudo ip link set macvlan1 up

---
v4: Added code to check for a non-empty list of macvlans before deleting them

v3: Renamed i40e_remove_macvlan_channels() to i40e_free_macvlan_channels()
Fixed an indentation issue and added some comments Removed a code name from the commit message Addressed some more of Shannon's comments

Quoted 7 lines

v2: Addressed Shannon's comments
Added a new function to remove all macvlan VSIs

 drivers/net/ethernet/intel/i40e/i40e.h      |  26 ++
 drivers/net/ethernet/intel/i40e/i40e_main.c | 484 +++++++++++++++++++-
 2 files changed, 508 insertions(+), 2 deletions(-)

Step 2 and 3 in the example to configure macvlans are the same except for the use of sudo (which I suspect Jeff can fix up without another spin.) Aside from that:

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

Signature · 2 lines
==============================================
Mr. Shannon Nelson         Parents can't afford to be squeamish.