Skip to contentSkip to conversation

l2 hardware accelerated macvlans

PATCH Superseded John Fastabend 3 participants 11 messages Nov 4, 2013 – Nov 5, 2013

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover l2 hardware accelerated macvlans

This patch adds support to offload macvlan net_devices to the hardware. With these patches packets are pushed to the macvlan net_device directly and do not pass through the lower dev.

The patches here have made it through multiple iterations each with a slightly different focus. First I tried to push these as a new link type called "VMDQ". The patches shown here,

http://comments.gmane.org/gmane.linux.network/237617

Following this implementation I renamed the link type "VSI" and addressed various comments. Finally Neil Horman picked up the patches and integrated the offload into the macvlan code. Here,

http://permalink.gmane.org/gmane.linux.network/285658

The attached series is clean-up of his patches, with a few fixes. I suspect Neil will add his signed-off-by line assuming I didn't mangle anything.

If folks find this series acceptable there are a few items we can work on next. First broadcast and multicast will use the hardware even for local traffic with this series. It would be best (I think) to use the software path for macvlan to macvlan traffic and save the PCIe bus. Also this only allows for layer 2 mac forwarding where some hardware supports more interesting forwarding capabilities. Integrating with OVS may be useful here.

As always any comments/feedback welcome.

I'm going to continue testing these on top of ixgbe but I believe these are stable and wanted to get them out to a wider audience. I've tested multiple offloaded macvlans with iperf and netperf using multiple sessions of each and seen no issues.

My basic I/O test is here but I've also done some link testing and others,

#ip link add link eth2 numtxqueues 4 numrxqueues 4 txqueuelen 50 type macvlan #tc qdisc add dev macvlan0 mq
#iperf -c 10.0.0.1 -P 8 -t 5000 -i 10

Changelog:
v2: two fixes to ixgbe when all features DCB, FCoE, SR-IOV
are enabled with macvlans. A VMDQ_P() reference should have been accel->pool and do not set the offset of the ring index from dfwd add call. The offset is used by SR-IOV so clearing it can cause SR-IOV quue index's to go sideways. With these fixes testing macvlan's with SRIOV enabled was successful.

Thanks,
John

---

John Fastabend (2):
ixgbe: enable l2 forwarding acceleration for macvlans
net: Add layer 2 hardware acceleration operations for macvlan devices

 drivers/net/ethernet/intel/ixgbe/ixgbe.h      |   20 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c  |   12 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  463 +++++++++++++++++++++----
 drivers/net/macvlan.c                         |   36 ++
 include/linux/if_macvlan.h                    |    1 
 include/linux/netdev_features.h               |    2 
 include/linux/netdevice.h                     |   36 ++
 include/uapi/linux/if.h                       |    1 
 net/core/dev.c                                |   18 +
 net/core/ethtool.c                            |    1 
 net/sched/sch_generic.c                       |    2 
 11 files changed, 504 insertions(+), 88 deletions(-)
Signature · 1 line
Signature
#1 lore raw

PATCH v2 1/2 net: Add layer 2 hardware acceleration operations for macvlan devices

Add a operations structure that allows a network interface to export the fact that it supports package forwarding in hardware between physical interfaces and other mac layer devices assigned to it (such as macvlans). This operaions structure can be used by virtual mac devices to bypass software switching so that forwarding can be done in hardware more efficiently.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

---

 drivers/net/macvlan.c           |   36 +++++++++++++++++++++++++++++++++++-
 include/linux/if_macvlan.h      |    1 +
 include/linux/netdev_features.h |    2 ++
 include/linux/netdevice.h       |   36 +++++++++++++++++++++++++++++++++++-
 include/uapi/linux/if.h         |    1 +
 net/core/dev.c                  |   18 +++++++++++++-----
 net/core/ethtool.c              |    1 +
 net/sched/sch_generic.c         |    2 +-
 8 files changed, 89 insertions(+), 8 deletions(-)
drivers/net/macvlan.c +35 -1
index cc9845e..eb68dd0 100644
@@ -297,7 +297,13 @@ netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
 	int ret;
 	const struct macvlan_dev *vlan = netdev_priv(dev);
 
-	ret = macvlan_queue_xmit(skb, dev);
+	if (vlan->fwd_priv) {
+		skb->dev = vlan->lowerdev;
+		ret = dev_hard_start_xmit(skb, skb->dev, NULL, vlan->fwd_priv);
+	} else {
+		ret = macvlan_queue_xmit(skb, dev);
+	}
+
 	if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
 		struct macvlan_pcpu_stats *pcpu_stats;
 
@@ -347,6 +353,21 @@ static int macvlan_open(struct net_device *dev)
 		goto hash_add;
 	}
 
+	if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD) {
+		vlan->fwd_priv =
+		      lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev);
+
+		 /* If we get a NULL pointer back, or if we get an error
+		  * then we should just fall through to the non accelerated path
+		  */
+		if (IS_ERR_OR_NULL(vlan->fwd_priv)) {
+			vlan->fwd_priv = NULL;
+		} else {
+			dev->features &= ~NETIF_F_LLTX;
+			return 0;
+		}
+	}
+
 	err = -EBUSY;
 	if (macvlan_addr_busy(vlan->port, dev->dev_addr))
 		goto out;
@@ -367,6 +388,11 @@ hash_add:
 del_unicast:
 	dev_uc_del(lowerdev, dev->dev_addr);
 out:
+	if (vlan->fwd_priv) {
+		lowerdev->netdev_ops->ndo_dfwd_del_station(lowerdev,
+							   vlan->fwd_priv);
+		vlan->fwd_priv = NULL;
+	}
 	return err;
 }
 
@@ -375,6 +401,13 @@ static int macvlan_stop(struct net_device *dev)
 	struct macvlan_dev *vlan = netdev_priv(dev);
 	struct net_device *lowerdev = vlan->lowerdev;
 
+	if (vlan->fwd_priv) {
+		lowerdev->netdev_ops->ndo_dfwd_del_station(lowerdev,
+							   vlan->fwd_priv);
+		vlan->fwd_priv = NULL;
+		return 0;
+	}
+
 	dev_uc_unsync(lowerdev, dev);
 	dev_mc_unsync(lowerdev, dev);
 
@@ -833,6 +866,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 	if (err < 0)
 		goto destroy_port;
 
+	dev->priv_flags |= IFF_MACVLAN;
 	err = netdev_upper_dev_link(lowerdev, dev);
 	if (err)
 		goto destroy_port;
include/linux/if_macvlan.h +1 -0
index ddd33fd..c270285 100644
@@ -61,6 +61,7 @@ struct macvlan_dev {
 	struct hlist_node	hlist;
 	struct macvlan_port	*port;
 	struct net_device	*lowerdev;
+	void			*fwd_priv;
 	struct macvlan_pcpu_stats __percpu *pcpu_stats;
 
 	DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ);
include/linux/netdev_features.h +2 -0
index b05a4b5..1005ebf 100644
@@ -62,6 +62,7 @@ enum {
 	NETIF_F_HW_VLAN_STAG_TX_BIT,	/* Transmit VLAN STAG HW acceleration */
 	NETIF_F_HW_VLAN_STAG_RX_BIT,	/* Receive VLAN STAG HW acceleration */
 	NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
+	NETIF_F_HW_L2FW_DOFFLOAD_BIT,	/* Allow L2 Forwarding in Hardware */
 
 	/*
 	 * Add your fresh new feature above and remember to update
@@ -116,6 +117,7 @@ enum {
 #define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)
 #define NETIF_F_HW_VLAN_STAG_RX	__NETIF_F(HW_VLAN_STAG_RX)
 #define NETIF_F_HW_VLAN_STAG_TX	__NETIF_F(HW_VLAN_STAG_TX)
+#define NETIF_F_HW_L2FW_DOFFLOAD	__NETIF_F(HW_L2FW_DOFFLOAD)
 
 /* Features valid for ethtool to change */
 /* = all defined minus driver/device-class-related */
include/linux/netdevice.h +35 -1
index e6353ca..d62c130 100644
@@ -962,6 +962,25 @@ struct netdev_phys_port_id {
  *	Called by vxlan to notify the driver about a UDP port and socket
  *	address family that vxlan is not listening to anymore. The operation
  *	is protected by the vxlan_net->sock_lock.
+ *
+ * void* (*ndo_dfwd_add_station)(struct net_device *pdev,
+ *				 struct net_device *dev)
+ *	Called by upper layer devices to accelerate switching or other
+ *	station functionality into hardware. 'pdev is the lowerdev
+ *	to use for the offload and 'dev' is the net device that will
+ *	back the offload. Returns a pointer to the private structure
+ *	the upper layer will maintain.
+ * void (*ndo_dfwd_del_station)(struct net_device *pdev, void *priv)
+ *	Called by upper layer device to delete the station created
+ *	by 'ndo_dfwd_add_station'. 'pdev' is the net device backing
+ *	the station and priv is the structure returned by the add
+ *	operation.
+ * netdev_tx_t (*ndo_dfwd_start_xmit)(struct sk_buff *skb,
+ *				      struct net_device *dev,
+ *				      void *priv);
+ *	Callback to use for xmit over the accelerated station. This
+ *	is used in place of ndo_start_xmit on accelerated net
+ *	devices.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1098,6 +1117,15 @@ struct net_device_ops {
 	void			(*ndo_del_vxlan_port)(struct  net_device *dev,
 						      sa_family_t sa_family,
 						      __be16 port);
+
+	void*			(*ndo_dfwd_add_station)(struct net_device *pdev,
+							struct net_device *dev);
+	void			(*ndo_dfwd_del_station)(struct net_device *pdev,
+							void *priv);
+
+	netdev_tx_t		(*ndo_dfwd_start_xmit) (struct sk_buff *skb,
+							struct net_device *dev,
+							void *priv);
 };
 
 /*
@@ -1195,6 +1223,7 @@ struct net_device {
 	/* Management operations */
 	const struct net_device_ops *netdev_ops;
 	const struct ethtool_ops *ethtool_ops;
+	const struct forwarding_accel_ops *fwd_ops;
 
 	/* Hardware header description */
 	const struct header_ops *header_ops;
@@ -2388,7 +2417,7 @@ int dev_change_carrier(struct net_device *, bool new_carrier);
 int dev_get_phys_port_id(struct net_device *dev,
 			 struct netdev_phys_port_id *ppid);
 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
-			struct netdev_queue *txq);
+			struct netdev_queue *txq, void *accel_priv);
 int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
 
 extern int		netdev_budget;
@@ -2967,6 +2996,11 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
 	dev->gso_max_size = size;
 }
 
+static inline bool netif_is_macvlan(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_MACVLAN;
+}
+
 static inline bool netif_is_bond_master(struct net_device *dev)
 {
 	return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
include/uapi/linux/if.h +1 -0
index 1ec407b..d758163 100644
@@ -83,6 +83,7 @@
 #define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
 #define IFF_LIVE_ADDR_CHANGE 0x100000	/* device supports hardware address
 					 * change when it's running */
+#define IFF_MACVLAN 0x200000		/* Macvlan device */
 
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
net/core/dev.c +13 -5
index 0e61365..8ffc52e 100644
@@ -2538,7 +2538,7 @@ static inline int skb_needs_linearize(struct sk_buff *skb,
 }
 
 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
-			struct netdev_queue *txq)
+			struct netdev_queue *txq, void *accel_priv)
 {
 	const struct net_device_ops *ops = dev->netdev_ops;
 	int rc = NETDEV_TX_OK;
@@ -2604,9 +2604,13 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 			dev_queue_xmit_nit(skb, dev);
 
 		skb_len = skb->len;
-		rc = ops->ndo_start_xmit(skb, dev);
+		if (accel_priv)
+			rc = ops->ndo_dfwd_start_xmit(skb, dev, accel_priv);
+		else
+			rc = ops->ndo_start_xmit(skb, dev);
+
 		trace_net_dev_xmit(skb, rc, dev, skb_len);
-		if (rc == NETDEV_TX_OK)
+		if (rc == NETDEV_TX_OK && txq)
 			txq_trans_update(txq);
 		return rc;
 	}
@@ -2622,7 +2626,10 @@ gso:
 			dev_queue_xmit_nit(nskb, dev);
 
 		skb_len = nskb->len;
-		rc = ops->ndo_start_xmit(nskb, dev);
+		if (accel_priv)
+			rc = ops->ndo_dfwd_start_xmit(nskb, dev, accel_priv);
+		else
+			rc = ops->ndo_start_xmit(nskb, dev);
 		trace_net_dev_xmit(nskb, rc, dev, skb_len);
 		if (unlikely(rc != NETDEV_TX_OK)) {
 			if (rc & ~NETDEV_TX_MASK)
@@ -2647,6 +2654,7 @@ out_kfree_skb:
 out:
 	return rc;
 }
+EXPORT_SYMBOL_GPL(dev_hard_start_xmit);
 
 static void qdisc_pkt_len_init(struct sk_buff *skb)
 {
@@ -2854,7 +2862,7 @@ int dev_queue_xmit(struct sk_buff *skb)
 
 			if (!netif_xmit_stopped(txq)) {
 				__this_cpu_inc(xmit_recursion);
-				rc = dev_hard_start_xmit(skb, dev, txq);
+				rc = dev_hard_start_xmit(skb, dev, txq, NULL);
 				__this_cpu_dec(xmit_recursion);
 				if (dev_xmit_complete(rc)) {
 					HARD_TX_UNLOCK(dev, txq);
net/core/ethtool.c +1 -0
index 8629898..30071de 100644
@@ -96,6 +96,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
 	[NETIF_F_LOOPBACK_BIT] =         "loopback",
 	[NETIF_F_RXFCS_BIT] =            "rx-fcs",
 	[NETIF_F_RXALL_BIT] =            "rx-all",
+	[NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
 };
 
 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
net/sched/sch_generic.c +1 -1
index 7fc899a..922a094 100644
@@ -126,7 +126,7 @@ int sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
 
 	HARD_TX_LOCK(dev, txq, smp_processor_id());
 	if (!netif_xmit_frozen_or_stopped(txq))
-		ret = dev_hard_start_xmit(skb, dev, txq);
+		ret = dev_hard_start_xmit(skb, dev, txq, NULL);
 
 	HARD_TX_UNLOCK(dev, txq);
 
#2 lore raw

Re: [PATCH v2 1/2] net: Add layer 2 hardware acceleration operations for macvlan devices

Quoted 10 lines · John Fastabend

Add a operations structure that allows a network interface to export the fact that it supports package forwarding in hardware between physical interfaces and other mac layer devices assigned to it (such as macvlans). This operaions structure can be used by virtual mac devices to bypass software switching so that forwarding can be done in hardware more efficiently.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

For when you send your V3 patch set out:

#3 lore raw

PATCH v2 2/2 ixgbe: enable l2 forwarding acceleration for macvlans

In reply to John Fastabend

Now that l2 acceleration ops are in place from the prior patch, enable ixgbe to take advantage of these operations. Allow it to allocate queues for a macvlan so that when we transmit a frame, we can do the switching in hardware inside the ixgbe card, rather than in software.

For now this patch limits the hardware to 8 offloaded macvlan ports. A follow on patch will remove this limitation but to simplify review/validation of the new macvlan offload ops we leave it at 8 for now.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

---

 drivers/net/ethernet/intel/ixgbe/ixgbe.h      |   20 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c  |   12 +
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  463 +++++++++++++++++++++----
 3 files changed, 415 insertions(+), 80 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +19 -1
index 0914914..236d4fb 100644
@@ -223,6 +223,15 @@ enum ixgbe_ring_state_t {
 	__IXGBE_RX_FCOE,
 };
 
+struct ixgbe_fwd_adapter {
+	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
+	struct net_device *netdev;
+	struct ixgbe_adapter *real_adapter;
+	unsigned int tx_base_queue;
+	unsigned int rx_base_queue;
+	int pool;
+};
+
 #define check_for_tx_hang(ring) \
 	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
 #define set_check_for_tx_hang(ring) \
@@ -240,6 +249,7 @@ struct ixgbe_ring {
 	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
 	struct net_device *netdev;	/* netdev ring belongs to */
 	struct device *dev;		/* device for DMA mapping */
+	struct ixgbe_fwd_adapter *l2_accel_priv;
 	void *desc;			/* descriptor ring memory */
 	union {
 		struct ixgbe_tx_buffer *tx_buffer_info;
@@ -292,11 +302,15 @@ enum ixgbe_ring_f_enum {
 };
 
 #define IXGBE_MAX_RSS_INDICES  16
-#define IXGBE_MAX_VMDQ_INDICES 64
+#define IXGBE_MAX_VMDQ_INDICES	8
 #define IXGBE_MAX_FDIR_INDICES 63	/* based on q_vector limit */
 #define IXGBE_MAX_FCOE_INDICES  8
 #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
 #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
+#define IXGBE_MAX_L2A_QUEUES 4
+#define IXGBE_MAX_L2A_QUEUES 4
+#define IXGBE_BAD_L2A_QUEUE 3
+
 struct ixgbe_ring_feature {
 	u16 limit;	/* upper limit on feature indices */
 	u16 indices;	/* current value of indices */
@@ -766,6 +780,7 @@ struct ixgbe_adapter {
 #endif /*CONFIG_DEBUG_FS*/
 
 	u8 default_up;
+	unsigned long fwd_bitmask; /* Bitmask indicating in use pools */
 };
 
 struct ixgbe_fdir_filter {
@@ -939,4 +954,7 @@ void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr);
 void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
 #endif
 
+netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
+				  struct ixgbe_adapter *adapter,
+				  struct ixgbe_ring *tx_ring);
 #endif /* _IXGBE_H_ */
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +10 -2
index 90b4e10..5eae76a 100644
@@ -852,7 +852,11 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,
 
 		/* apply Tx specific ring traits */
 		ring->count = adapter->tx_ring_count;
-		ring->queue_index = txr_idx;
+		if (adapter->num_rx_pools > 1)
+			ring->queue_index =
+				txr_idx % adapter->num_rx_queues_per_pool;
+		else
+			ring->queue_index = txr_idx;
 
 		/* assign ring to adapter */
 		adapter->tx_ring[txr_idx] = ring;
@@ -895,7 +899,11 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,
 #endif /* IXGBE_FCOE */
 		/* apply Rx specific ring traits */
 		ring->count = adapter->rx_ring_count;
-		ring->queue_index = rxr_idx;
+		if (adapter->num_rx_pools > 1)
+			ring->queue_index =
+				rxr_idx % adapter->num_rx_queues_per_pool;
+		else
+			ring->queue_index = rxr_idx;
 
 		/* assign ring to adapter */
 		adapter->rx_ring[rxr_idx] = ring;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +386 -77

608 lines not on this page · raw message

#4 lore raw

Re: [PATCH v2 2/2] ixgbe: enable l2 forwarding acceleration for macvlans

Quoted 15 lines · John Fastabend

Now that l2 acceleration ops are in place from the prior patch, enable ixgbe to take advantage of these operations. Allow it to allocate queues for a macvlan so that when we transmit a frame, we can do the switching in hardware inside the ixgbe card, rather than in software.

For now this patch limits the hardware to 8 offloaded macvlan ports. A follow on patch will remove this limitation but to simplify review/validation of the new macvlan offload ops we leave it at 8 for now.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

---

[...]

drivers/net/ethernet/intel/ixgbe/ixgbe.h enum ixgbe_ring_f_enum { · line 305

Quoted 4 lines
  #define IXGBE_MAX_RSS_INDICES  16
drivers/net/ethernet/intel/ixgbe/ixgbe.h +1 -1
-#define IXGBE_MAX_VMDQ_INDICES 64
+#define IXGBE_MAX_VMDQ_INDICES	8

This define is also used for max VFs in SR-IOV mode so we can't just redefine it like this without also limiting SR-IOV.

[...]

Quoted 5 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -0
+static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
+{
+	struct ixgbe_fwd_adapter *fwd_adapter = priv;
+	struct ixgbe_adapter *adapter = fwd_adapter->real_adapter;
+

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, · line 7591

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10 -0
+	clear_bit(fwd_adapter->pool, &adapter->fwd_bitmask);
+	adapter->num_rx_pools--;
+
+	ixgbe_fwd_ring_down(fwd_adapter->netdev, fwd_adapter);
+
+	netdev_dbg(pdev, "pool %i:%i queues %i:%i VSI bitmask %lx\n",
+		   fwd_adapter->pool, adapter->num_rx_pools,
+		   fwd_adapter->rx_base_queue,
+		   fwd_adapter->rx_base_queue + adapter->num_rx_queues_per_pool,
+		   adapter->fwd_bitmask);

Missing a kfree(fwd_adapter) here, and a ixgbe_setup_tc() call to release the queues.

I'm testing a fix now and will send a v3.

Thanks,
John

#5 lore raw

Re: [PATCH v2 2/2] ixgbe: enable l2 forwarding acceleration for macvlans

In reply to John Fastabend
Quoted 6 lines · John Fastabend

Now that l2 acceleration ops are in place from the prior patch, enable ixgbe to take advantage of these operations. Allow it to allocate queues for a macvlan so that when we transmit a frame, we can do the switching in hardware inside the ixgbe card, rather than in software.

Quoted 8 lines

For now this patch limits the hardware to 8 offloaded macvlan ports. A follow on patch will remove this limitation but to simplify review/validation of the new macvlan offload ops we leave it at 8 for now.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

A few Nits, since you're going to send a V3 anyway. Comments inline.

Quoted 10 lines

---
<snip>

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +8 -0
+static void ixgbe_configure_vsi(struct ixgbe_adapter *adapter)
+{
+	struct net_device *upper;
+	struct list_head *iter;
+	int err;
+
+	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
+		if (netif_is_macvlan(upper)) {

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter) · line 4313

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10 -0
+			struct macvlan_dev *vlan = netdev_priv(upper);
+			struct ixgbe_fwd_adapter *vadapter = vlan->fwd_priv;
+
+			if (vlan->fwd_priv) {
+				err = ixgbe_fwd_ring_up(upper, vadapter);
+				if (err)
+					continue;
+				ixgbe_macvlan_set_rx_mode(upper,
+							  vadapter->pool,
+							  adapter);

Nit: You're using macvlan here, and vsi above. Might be nice to give everything a consistent suffix/prefix for clarity. Perhaps dfwd since thats what the new ndo_ops uses?

Quoted 16 lines

<snip>

static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw)

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -0
@@ -4317,6 +4521,8 @@ static void ixgbe_setup_gpie(struct ixgbe_adapter *adapter)
 static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
 {
 	struct ixgbe_hw *hw = &adapter->hw;
+	struct net_device *upper;
+	struct list_head *iter;
 	int err;
 	u32 ctrl_ext;
 
@@ -4360,6 +4566,16 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
 	/* enable transmits */
 	netif_tx_start_all_queues(adapter->netdev);
 

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_up_complete(struct ixgbe_adapter *adapter) · line 4578

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +10 -0
+	/* enable any upper devices */
+	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
+		if (netif_is_macvlan(upper)) {
+			struct macvlan_dev *vlan = netdev_priv(upper);
+
+			if (vlan->fwd_priv)
+				netif_tx_start_all_queues(upper);
+		}
+	}
+

I don't think it matters much, but do we want to start the upper devs queues here unilaterally? Nominally a network interface starts its queues on dev_open. Would it be better to only start those devices if (vlan->fwd_priv && (upper->flags & IFF_UP)? We would then have to listen for NETDEV_UP events as well to handle accelerated macvlans comming up after ixgbe does, which is more work, but I wanted to mention this in case theres some disadvantage to starting the queue early.

Other than that I think it looks good though. Nice work!

Regards
Neil

#6 lore raw

Re: [PATCH v2 2/2] ixgbe: enable l2 forwarding acceleration for macvlans

Quoted 19 lines · Neil Horman
Quoted 6 lines · John Fastabend

Now that l2 acceleration ops are in place from the prior patch, enable ixgbe to take advantage of these operations. Allow it to allocate queues for a macvlan so that when we transmit a frame, we can do the switching in hardware inside the ixgbe card, rather than in software.

Quoted 8 lines

For now this patch limits the hardware to 8 offloaded macvlan ports. A follow on patch will remove this limitation but to simplify review/validation of the new macvlan offload ops we leave it at 8 for now.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

A few Nits, since you're going to send a V3 anyway. Comments inline.

Quoted 1 line

---

[...]

Quoted 4 lines

Nit: You're using macvlan here, and vsi above. Might be nice to give everything a consistent suffix/prefix for clarity. Perhaps dfwd since thats what the new ndo_ops uses?

using dfwd now.

Quoted 25 lines
Quoted 25 lines

<snip>

static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw)

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +11 -0
@@ -4317,6 +4521,8 @@ static void ixgbe_setup_gpie(struct ixgbe_adapter *adapter)
  static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
  {
  	struct ixgbe_hw *hw = &adapter->hw;
+	struct net_device *upper;
+	struct list_head *iter;
  	int err;
  	u32 ctrl_ext;
 
@@ -4360,6 +4566,16 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
  	/* enable transmits */
  	netif_tx_start_all_queues(adapter->netdev);
 
+	/* enable any upper devices */
+	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
+		if (netif_is_macvlan(upper)) {
+			struct macvlan_dev *vlan = netdev_priv(upper);
+
+			if (vlan->fwd_priv)
+				netif_tx_start_all_queues(upper);
+		}
+	}
Quoted 9 lines

Review static void ixgbe_up_complete(struct ixgbe_adapter *adapter) · line 4578

Quoted 1 line
(quoted diff) +1 -0
+

I don't think it matters much, but do we want to start the upper devs queues here unilaterally? Nominally a network interface starts its queues on dev_open. Would it be better to only start those devices if (vlan->fwd_priv && (upper->flags & IFF_UP)? We would then have to listen for NETDEV_UP events as well to handle accelerated macvlans comming up after ixgbe does, which is more work, but I wanted to mention this in case theres some disadvantage to starting the queue early.

vlan->fwd_priv is set in macvlan_open() and cleared in macvlan_close() and serialized with the rtnl lock. So I think anytime you get here and have vlan->fwd_priv non-null its the same as IFF_UP being set.

The only call sites I see changing the IFF_UP flag are dev_open() and dev_close() and derivatives. Each calls ndo_open and ndo_close. So assuming I didn't miss some call sites the above seems correct.

Quoted 3 lines

Other than that I think it looks good though. Nice work!

Great thanks for looking it over. I should have v3 out here shortly doing a couple more tests for feature interop.

Quoted 8 lines

Regards
Neil

--
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

#7 lore raw

Re: [PATCH v2 2/2] ixgbe: enable l2 forwarding acceleration for macvlans

Quoted 75 lines · John Fastabend
Quoted 19 lines · Neil Horman
Quoted 6 lines · John Fastabend

Now that l2 acceleration ops are in place from the prior patch, enable ixgbe to take advantage of these operations. Allow it to allocate queues for a macvlan so that when we transmit a frame, we can do the switching in hardware inside the ixgbe card, rather than in software.

Quoted 8 lines

For now this patch limits the hardware to 8 offloaded macvlan ports. A follow on patch will remove this limitation but to simplify review/validation of the new macvlan offload ops we leave it at 8 for now.

CC Andy Gospodarek <[email protected]>
CC "David S. Miller" <[email protected]>

A few Nits, since you're going to send a V3 anyway. Comments inline.

Quoted 1 line

---

[...]

Quoted 4 lines

Nit: You're using macvlan here, and vsi above. Might be nice to give everything a consistent suffix/prefix for clarity. Perhaps dfwd since thats what the new ndo_ops uses?

using dfwd now.

Quoted 25 lines
Quoted 25 lines

<snip>

static inline bool ixgbe_is_sfp(struct ixgbe_hw *hw)

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +11 -0
@@ -4317,6 +4521,8 @@ static void ixgbe_setup_gpie(struct ixgbe_adapter *adapter)
 static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
 {
 	struct ixgbe_hw *hw = &adapter->hw;
+	struct net_device *upper;
+	struct list_head *iter;
 	int err;
 	u32 ctrl_ext;
 
@@ -4360,6 +4566,16 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter)
 	/* enable transmits */
 	netif_tx_start_all_queues(adapter->netdev);
 
+	/* enable any upper devices */
+	netdev_for_each_all_upper_dev_rcu(adapter->netdev, upper, iter) {
+		if (netif_is_macvlan(upper)) {
+			struct macvlan_dev *vlan = netdev_priv(upper);
+
+			if (vlan->fwd_priv)
+				netif_tx_start_all_queues(upper);
+		}
+	}
Quoted 9 lines

Review static void ixgbe_up_complete(struct ixgbe_adapter *adapter) · line 4578

Quoted 1 line
(quoted diff) +1 -0
+

I don't think it matters much, but do we want to start the upper devs queues here unilaterally? Nominally a network interface starts its queues on dev_open. Would it be better to only start those devices if (vlan->fwd_priv && (upper->flags & IFF_UP)? We would then have to listen for NETDEV_UP events as well to handle accelerated macvlans comming up after ixgbe does, which is more work, but I wanted to mention this in case theres some disadvantage to starting the queue early.

vlan->fwd_priv is set in macvlan_open() and cleared in macvlan_close() and serialized with the rtnl lock. So I think anytime you get here and have vlan->fwd_priv non-null its the same as IFF_UP being set.

The only call sites I see changing the IFF_UP flag are dev_open() and dev_close() and derivatives. Each calls ndo_open and ndo_close. So assuming I didn't miss some call sites the above seems correct.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

Other than that I think it looks good though. Nice work!

Great thanks for looking it over. I should have v3 out here shortly doing a couple more tests for feature interop.

Copy that, I'll sign off on that version
Neil

Quoted 10 lines
Quoted 8 lines

Regards
Neil

--
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

#8 lore raw
In reply to John Fastabend

Hi John

Quoted 22 lines · John Fastabend

This patch adds support to offload macvlan net_devices to the hardware. With these patches packets are pushed to the macvlan net_device directly and do not pass through the lower dev.

The patches here have made it through multiple iterations each with a slightly different focus. First I tried to push these as a new link type called "VMDQ". The patches shown here,

http://comments.gmane.org/gmane.linux.network/237617

Following this implementation I renamed the link type "VSI" and addressed various comments. Finally Neil Horman picked up the patches and integrated the offload into the macvlan code. Here,

http://permalink.gmane.org/gmane.linux.network/285658

The attached series is clean-up of his patches, with a few fixes. I suspect Neil will add his signed-off-by line assuming I didn't mangle anything.

Quoted 8 lines

If folks find this series acceptable there are a few items we can work on next. First broadcast and multicast will use the hardware even for local traffic with this series. It would be best (I think) to use the software path for macvlan to macvlan traffic and save the PCIe bus. Also this only allows for layer 2 mac forwarding where some hardware supports more interesting forwarding capabilities. Integrating with OVS may be useful here.

This seems to be saying that for macvlan-macvlan case, you still prefere to do software based forwarding, but patch 1 in the series seem to always attempt to do hardware offloaded forwarding regardless of traffic and macvlan type. Can you clarify.

Thanks
-vlad

Quoted 48 lines

As always any comments/feedback welcome.

I'm going to continue testing these on top of ixgbe but I believe these are stable and wanted to get them out to a wider audience. I've tested multiple offloaded macvlans with iperf and netperf using multiple sessions of each and seen no issues.

My basic I/O test is here but I've also done some link testing and others,

#ip link add link eth2 numtxqueues 4 numrxqueues 4 txqueuelen 50 type macvlan #tc qdisc add dev macvlan0 mq
#iperf -c 10.0.0.1 -P 8 -t 5000 -i 10

Changelog:
v2: two fixes to ixgbe when all features DCB, FCoE, SR-IOV
are enabled with macvlans. A VMDQ_P() reference should have been accel->pool and do not set the offset of the ring index from dfwd add call. The offset is used by SR-IOV so clearing it can cause SR-IOV quue index's to go sideways. With these fixes testing macvlan's with SRIOV enabled was successful.

Thanks,
John

---

John Fastabend (2):
ixgbe: enable l2 forwarding acceleration for macvlans
net: Add layer 2 hardware acceleration operations for macvlan devices

  drivers/net/ethernet/intel/ixgbe/ixgbe.h      |   20 +
  drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c  |   12 +
  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  463 +++++++++++++++++++++----
  drivers/net/macvlan.c                         |   36 ++
  include/linux/if_macvlan.h                    |    1
  include/linux/netdev_features.h               |    2
  include/linux/netdevice.h                     |   36 ++
  include/uapi/linux/if.h                       |    1
  net/core/dev.c                                |   18 +
  net/core/ethtool.c                            |    1
  net/sched/sch_generic.c                       |    2
  11 files changed, 504 insertions(+), 88 deletions(-)
#9 lore raw
Quoted 2 lines · Vlad Yasevich

Hi John

[...]

Quoted 6 lines
Quoted 5 lines

series. It would be best (I think) to use the software path for macvlan to macvlan traffic and save the PCIe bus. Also this only allows for layer 2 mac forwarding where some hardware supports more interesting forwarding capabilities. Integrating with OVS may be useful here.

Quoted 9 lines

This seems to be saying that for macvlan-macvlan case, you still prefere to do software based forwarding, but patch 1 in the series seem to always attempt to do hardware offloaded forwarding regardless of traffic and macvlan type. Can you clarify.

Thanks
-vlad

This series always attempts to do hardware offload even in the macvlan-macvlan case as you note. I'm suggesting a further optimization might be to use the software based forwarding in this case. My plan is to investigate this after I get the initial series completed.

.John

#10 lore raw
Quoted 22 lines · John Fastabend
Quoted 2 lines · Vlad Yasevich

Hi John

[...]

Quoted 6 lines
Quoted 5 lines

series. It would be best (I think) to use the software path for macvlan to macvlan traffic and save the PCIe bus. Also this only allows for layer 2 mac forwarding where some hardware supports more interesting forwarding capabilities. Integrating with OVS may be useful here.

Quoted 9 lines

This seems to be saying that for macvlan-macvlan case, you still prefere to do software based forwarding, but patch 1 in the series seem to always attempt to do hardware offloaded forwarding regardless of traffic and macvlan type. Can you clarify.

Thanks
-vlad

Quoted 6 lines

This series always attempts to do hardware offload even in the macvlan-macvlan case as you note. I'm suggesting a further optimization might be to use the software based forwarding in this case. My plan is to investigate this after I get the initial series completed.

Ahh. Got it.

Thanks
-vlad