From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Samudrala, Sridhar" Subject: Re: [Intel-wired-lan] [next-queue v6 PATCH 5/7] i40e: Add TX and RX support over port netdev's in switchdev mode Date: Fri, 14 Apr 2017 11:26:25 -0700 Message-ID: <58F11451.9020104@intel.com> References: <1490833375-2788-1-git-send-email-sridhar.samudrala@intel.com> <1490833375-2788-6-git-send-email-sridhar.samudrala@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: intel-wired-lan , Netdev , "Duyck, Alexander H" , Anjali Singhai Jain , Jakub Kicinski , Or Gerlitz , Jiri Pirko To: Alexander Duyck Return-path: Received: from mga04.intel.com ([192.55.52.120]:9587 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754147AbdDNS00 (ORCPT ); Fri, 14 Apr 2017 14:26:26 -0400 In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On 4/14/2017 9:47 AM, Alexander Duyck wrote: > On Wed, Mar 29, 2017 at 5:22 PM, Sridhar Samudrala > wrote: >> In switchdev mode, broadcasts from VFs are received by the PF and passed >> to corresponding port representor netdev. >> Any frames sent via port netdevs are sent as directed transmits to the >> corresponding VFs. To enable directed transmit, skb metadata dst is used >> to pass the port id and the frame is requeued to call the PFs transmit >> routine. VF id is used as port id for VFs and PF port id is defined as >> I40_MAIN_VSI_PORT_ID. >> >> Small script to demonstrate inter VF and PF to VF pings in switchdev mode. >> PF: p4p1, VFs: p4p1_0,p4p1_1 VF Port Reps:p4p1-vf0, p4p1-vf1 >> PF Port rep: p4p1-pf >> >> # rmmod i40e; modprobe i40e >> # devlink dev eswitch set pci/0000:05:00.0 mode switchdev >> # echo 2 > /sys/class/net/p4p1/device/sriov_numvfs >> # ip link set p4p1 vf 0 mac 00:11:22:33:44:55 >> # ip link set p4p1 vf 1 mac 00:11:22:33:44:56 >> # rmmod i40evf; modprobe i40evf >> >> /* Create 2 namespaces and move the VFs to the corresponding ns */ >> # ip netns add ns0 >> # ip link set p4p1_0 netns ns0 >> # ip netns exec ns0 ip addr add 192.168.1.10/24 dev p4p1_0 >> # ip netns exec ns0 ip link set p4p1_0 up >> # ip netns add ns1 >> # ip link set p4p1_1 netns ns1 >> # ip netns exec ns1 ip addr add 192.168.1.11/24 dev p4p1_1 >> # ip netns exec ns1 ip link set p4p1_1 up >> >> /* bring up pf and port netdevs */ >> # ip addr add 192.168.1.1/24 dev p4p1 >> # ip link set p4p1 up >> # ip link set p4p1-vf0 up >> # ip link set p4p1-vf1 up >> # ip link set p4p1-pf up >> >> # ip netns exec ns0 ping -c3 192.168.1.11 /* VF0 -> VF1 */ >> # ip netns exec ns1 ping -c3 192.168.1.10 /* VF1 -> VF0 */ >> # ping -c3 192.168.1.10 /* PF -> VF0 */ >> # ping -c3 192.168.1.11 /* PF -> VF1 */ >> >> /* VF0 -> IP in same subnet - broadcasts will be seen on p4p1-vf0 & p4p1 */ >> # ip netns exec ns0 ping -c1 -W1 192.168.1.200 >> /* VF1 -> IP in same subnet - broadcasts will be seen on p4p1-vf1 & p4p1*/ >> # ip netns exec ns0 ping -c1 -W1 192.168.1.200 >> /* port rep VF0 -> IP in same subnet - broadcasts will be seen on p4p1_0 */ >> # ping -I p4p1-vf0 -c1 -W1 192.168.1.200 >> /* port rep VF1 -> IP in same subnet - broadcasts will be seen on p4p1_1 */ >> # ping -I p4p1-vf1 -c1 -W1 192.168.1.200 >> >> Signed-off-by: Sridhar Samudrala >> --- >> drivers/net/ethernet/intel/i40e/i40e.h | 4 + >> drivers/net/ethernet/intel/i40e/i40e_main.c | 27 +++- >> drivers/net/ethernet/intel/i40e/i40e_txrx.c | 148 ++++++++++++++++++++- >> drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 + >> drivers/net/ethernet/intel/i40e/i40e_type.h | 3 + >> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 +- >> 6 files changed, 184 insertions(+), 8 deletions(-) >> > > >> diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> index ebffca0..86d2510 100644 >> --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> @@ -1302,20 +1302,64 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring, >> } >> >> /** >> + * i40e_handle_lpbk_skb - Update skb->dev of a loopback frame >> + * @rx_ring: rx ring in play >> + * @skb: packet to send up >> + **/ >> +static void i40e_handle_lpbk_skb(struct i40e_ring *rx_ring, struct sk_buff *skb) >> +{ >> + struct i40e_q_vector *q_vector = rx_ring->q_vector; >> + struct i40e_pf *pf = rx_ring->vsi->back; >> + struct sk_buff *nskb; >> + struct i40e_vf *vf; >> + struct ethhdr *eth; >> + int vf_id; >> + >> + if ((skb->pkt_type != PACKET_BROADCAST) && >> + (skb->pkt_type != PACKET_MULTICAST) && >> + (skb->pkt_type != PACKET_OTHERHOST)) >> + return; >> + >> + eth = (struct ethhdr *)skb_mac_header(skb); >> + >> + /* If a loopback packet is received in switchdev mode, clone the skb >> + * and pass it to the corresponding port netdev based on the source MAC. >> + */ >> + for (vf_id = 0; vf_id < pf->num_alloc_vfs; vf_id++) { >> + vf = &pf->vf[vf_id]; >> + if (ether_addr_equal(eth->h_source, >> + vf->default_lan_addr.addr)) { >> + nskb = skb_clone(skb, GFP_ATOMIC); >> + if (!nskb) >> + break; >> + nskb->offload_fwd_mark = 1; > So this line is causing build errors when switchdev is not enabled. > This whole function should probably be wrapped in a check to see if > switchdev support is enabled or not. Yes. will fix it in the next revision. Thanks Sridhar From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samudrala, Sridhar Date: Fri, 14 Apr 2017 11:26:25 -0700 Subject: [Intel-wired-lan] [next-queue v6 PATCH 5/7] i40e: Add TX and RX support over port netdev's in switchdev mode In-Reply-To: References: <1490833375-2788-1-git-send-email-sridhar.samudrala@intel.com> <1490833375-2788-6-git-send-email-sridhar.samudrala@intel.com> Message-ID: <58F11451.9020104@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: On 4/14/2017 9:47 AM, Alexander Duyck wrote: > On Wed, Mar 29, 2017 at 5:22 PM, Sridhar Samudrala > wrote: >> In switchdev mode, broadcasts from VFs are received by the PF and passed >> to corresponding port representor netdev. >> Any frames sent via port netdevs are sent as directed transmits to the >> corresponding VFs. To enable directed transmit, skb metadata dst is used >> to pass the port id and the frame is requeued to call the PFs transmit >> routine. VF id is used as port id for VFs and PF port id is defined as >> I40_MAIN_VSI_PORT_ID. >> >> Small script to demonstrate inter VF and PF to VF pings in switchdev mode. >> PF: p4p1, VFs: p4p1_0,p4p1_1 VF Port Reps:p4p1-vf0, p4p1-vf1 >> PF Port rep: p4p1-pf >> >> # rmmod i40e; modprobe i40e >> # devlink dev eswitch set pci/0000:05:00.0 mode switchdev >> # echo 2 > /sys/class/net/p4p1/device/sriov_numvfs >> # ip link set p4p1 vf 0 mac 00:11:22:33:44:55 >> # ip link set p4p1 vf 1 mac 00:11:22:33:44:56 >> # rmmod i40evf; modprobe i40evf >> >> /* Create 2 namespaces and move the VFs to the corresponding ns */ >> # ip netns add ns0 >> # ip link set p4p1_0 netns ns0 >> # ip netns exec ns0 ip addr add 192.168.1.10/24 dev p4p1_0 >> # ip netns exec ns0 ip link set p4p1_0 up >> # ip netns add ns1 >> # ip link set p4p1_1 netns ns1 >> # ip netns exec ns1 ip addr add 192.168.1.11/24 dev p4p1_1 >> # ip netns exec ns1 ip link set p4p1_1 up >> >> /* bring up pf and port netdevs */ >> # ip addr add 192.168.1.1/24 dev p4p1 >> # ip link set p4p1 up >> # ip link set p4p1-vf0 up >> # ip link set p4p1-vf1 up >> # ip link set p4p1-pf up >> >> # ip netns exec ns0 ping -c3 192.168.1.11 /* VF0 -> VF1 */ >> # ip netns exec ns1 ping -c3 192.168.1.10 /* VF1 -> VF0 */ >> # ping -c3 192.168.1.10 /* PF -> VF0 */ >> # ping -c3 192.168.1.11 /* PF -> VF1 */ >> >> /* VF0 -> IP in same subnet - broadcasts will be seen on p4p1-vf0 & p4p1 */ >> # ip netns exec ns0 ping -c1 -W1 192.168.1.200 >> /* VF1 -> IP in same subnet - broadcasts will be seen on p4p1-vf1 & p4p1*/ >> # ip netns exec ns0 ping -c1 -W1 192.168.1.200 >> /* port rep VF0 -> IP in same subnet - broadcasts will be seen on p4p1_0 */ >> # ping -I p4p1-vf0 -c1 -W1 192.168.1.200 >> /* port rep VF1 -> IP in same subnet - broadcasts will be seen on p4p1_1 */ >> # ping -I p4p1-vf1 -c1 -W1 192.168.1.200 >> >> Signed-off-by: Sridhar Samudrala >> --- >> drivers/net/ethernet/intel/i40e/i40e.h | 4 + >> drivers/net/ethernet/intel/i40e/i40e_main.c | 27 +++- >> drivers/net/ethernet/intel/i40e/i40e_txrx.c | 148 ++++++++++++++++++++- >> drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 + >> drivers/net/ethernet/intel/i40e/i40e_type.h | 3 + >> drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 8 +- >> 6 files changed, 184 insertions(+), 8 deletions(-) >> > > >> diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> index ebffca0..86d2510 100644 >> --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c >> @@ -1302,20 +1302,64 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring, >> } >> >> /** >> + * i40e_handle_lpbk_skb - Update skb->dev of a loopback frame >> + * @rx_ring: rx ring in play >> + * @skb: packet to send up >> + **/ >> +static void i40e_handle_lpbk_skb(struct i40e_ring *rx_ring, struct sk_buff *skb) >> +{ >> + struct i40e_q_vector *q_vector = rx_ring->q_vector; >> + struct i40e_pf *pf = rx_ring->vsi->back; >> + struct sk_buff *nskb; >> + struct i40e_vf *vf; >> + struct ethhdr *eth; >> + int vf_id; >> + >> + if ((skb->pkt_type != PACKET_BROADCAST) && >> + (skb->pkt_type != PACKET_MULTICAST) && >> + (skb->pkt_type != PACKET_OTHERHOST)) >> + return; >> + >> + eth = (struct ethhdr *)skb_mac_header(skb); >> + >> + /* If a loopback packet is received in switchdev mode, clone the skb >> + * and pass it to the corresponding port netdev based on the source MAC. >> + */ >> + for (vf_id = 0; vf_id < pf->num_alloc_vfs; vf_id++) { >> + vf = &pf->vf[vf_id]; >> + if (ether_addr_equal(eth->h_source, >> + vf->default_lan_addr.addr)) { >> + nskb = skb_clone(skb, GFP_ATOMIC); >> + if (!nskb) >> + break; >> + nskb->offload_fwd_mark = 1; > So this line is causing build errors when switchdev is not enabled. > This whole function should probably be wrapped in a check to see if > switchdev support is enabled or not. Yes. will fix it in the next revision. Thanks Sridhar