diff mbox series

[1/1] IB: rxe: replace av->network_type with skb->protocol

Message ID 1551007606-9006-1-git-send-email-yanjun.zhu@oracle.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series [1/1] IB: rxe: replace av->network_type with skb->protocol | expand

Commit Message

Zhu Yanjun Feb. 24, 2019, 11:26 a.m. UTC
In the function rxe_init_packet, based on av->network_type,
skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
and rxe_send are called after the functin rxe_init_packet.
So in these functions, av->network_type can be replaced with
skb->protocol.
The functions are in the xmit fast path. So with skb->protocol,
the performance will be better.

Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
---
 drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Comments

Zhu Yanjun March 5, 2019, 8:52 a.m. UTC | #1
ping

On 2019/2/24 19:26, Zhu Yanjun wrote:
> In the function rxe_init_packet, based on av->network_type,
> skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
> and rxe_send are called after the functin rxe_init_packet.
> So in these functions, av->network_type can be replaced with
> skb->protocol.
> The functions are in the xmit fast path. So with skb->protocol,
> the performance will be better.
>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> ---
>   drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
>   1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> index 8fd03ae..edac208 100644
> --- a/drivers/infiniband/sw/rxe/rxe_net.c
> +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> @@ -368,13 +368,13 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb,
>   	ip6h->payload_len = htons(skb->len - sizeof(*ip6h));
>   }
>   
> -static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> -		    struct rxe_av *av)
> +static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb)
>   {
>   	struct rxe_qp *qp = pkt->qp;
>   	struct dst_entry *dst;
>   	bool xnet = false;
>   	__be16 df = htons(IP_DF);
> +	struct rxe_av *av = rxe_get_av(pkt);
>   	struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr;
>   	struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr;
>   
> @@ -397,11 +397,11 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
>   	return 0;
>   }
>   
> -static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> -		    struct rxe_av *av)
> +static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb)
>   {
>   	struct rxe_qp *qp = pkt->qp;
>   	struct dst_entry *dst;
> +	struct rxe_av *av = rxe_get_av(pkt);
>   	struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
>   	struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
>   
> @@ -428,12 +428,11 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
>   int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb, u32 *crc)
>   {
>   	int err = 0;
> -	struct rxe_av *av = rxe_get_av(pkt);
>   
> -	if (av->network_type == RDMA_NETWORK_IPV4)
> -		err = prepare4(pkt, skb, av);
> -	else if (av->network_type == RDMA_NETWORK_IPV6)
> -		err = prepare6(pkt, skb, av);
> +	if (skb->protocol == htons(ETH_P_IP))
> +		err = prepare4(pkt, skb);
> +	else if (skb->protocol == htons(ETH_P_IPV6))
> +		err = prepare6(pkt, skb);
>   
>   	*crc = rxe_icrc_hdr(pkt, skb);
>   
> @@ -455,23 +454,20 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb)
>   
>   int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb)
>   {
> -	struct rxe_av *av;
>   	int err;
>   
> -	av = rxe_get_av(pkt);
> -
>   	skb->destructor = rxe_skb_tx_dtor;
>   	skb->sk = pkt->qp->sk->sk;
>   
>   	rxe_add_ref(pkt->qp);
>   	atomic_inc(&pkt->qp->skb_out);
>   
> -	if (av->network_type == RDMA_NETWORK_IPV4) {
> +	if (skb->protocol == htons(ETH_P_IP)) {
>   		err = ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
> -	} else if (av->network_type == RDMA_NETWORK_IPV6) {
> +	} else if (skb->protocol == htons(ETH_P_IPV6)) {
>   		err = ip6_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
>   	} else {
> -		pr_err("Unknown layer 3 protocol: %d\n", av->network_type);
> +		pr_err("Unknown layer 3 protocol: %d\n", skb->protocol);
>   		atomic_dec(&pkt->qp->skb_out);
>   		rxe_drop_ref(pkt->qp);
>   		kfree_skb(skb);
Jason Gunthorpe March 7, 2019, 12:44 p.m. UTC | #2
We are in the merge window, patches are not being applied

Jason

On Tue, Mar 05, 2019 at 04:52:41PM +0800, Yanjun Zhu wrote:
> ping
> 
> On 2019/2/24 19:26, Zhu Yanjun wrote:
> > In the function rxe_init_packet, based on av->network_type,
> > skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
> > and rxe_send are called after the functin rxe_init_packet.
> > So in these functions, av->network_type can be replaced with
> > skb->protocol.
> > The functions are in the xmit fast path. So with skb->protocol,
> > the performance will be better.
> > 
> > Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> >   drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
> >   1 file changed, 11 insertions(+), 15 deletions(-)
> > 
> > diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
> > index 8fd03ae..edac208 100644
> > +++ b/drivers/infiniband/sw/rxe/rxe_net.c
> > @@ -368,13 +368,13 @@ static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb,
> >   	ip6h->payload_len = htons(skb->len - sizeof(*ip6h));
> >   }
> > -static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> > -		    struct rxe_av *av)
> > +static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb)
> >   {
> >   	struct rxe_qp *qp = pkt->qp;
> >   	struct dst_entry *dst;
> >   	bool xnet = false;
> >   	__be16 df = htons(IP_DF);
> > +	struct rxe_av *av = rxe_get_av(pkt);
> >   	struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr;
> >   	struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr;
> > @@ -397,11 +397,11 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> >   	return 0;
> >   }
> > -static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> > -		    struct rxe_av *av)
> > +static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb)
> >   {
> >   	struct rxe_qp *qp = pkt->qp;
> >   	struct dst_entry *dst;
> > +	struct rxe_av *av = rxe_get_av(pkt);
> >   	struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
> >   	struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
> > @@ -428,12 +428,11 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
> >   int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb, u32 *crc)
> >   {
> >   	int err = 0;
> > -	struct rxe_av *av = rxe_get_av(pkt);
> > -	if (av->network_type == RDMA_NETWORK_IPV4)
> > -		err = prepare4(pkt, skb, av);
> > -	else if (av->network_type == RDMA_NETWORK_IPV6)
> > -		err = prepare6(pkt, skb, av);
> > +	if (skb->protocol == htons(ETH_P_IP))
> > +		err = prepare4(pkt, skb);
> > +	else if (skb->protocol == htons(ETH_P_IPV6))
> > +		err = prepare6(pkt, skb);
> >   	*crc = rxe_icrc_hdr(pkt, skb);
> > @@ -455,23 +454,20 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb)
> >   int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb)
> >   {
> > -	struct rxe_av *av;
> >   	int err;
> > -	av = rxe_get_av(pkt);
> > -
> >   	skb->destructor = rxe_skb_tx_dtor;
> >   	skb->sk = pkt->qp->sk->sk;
> >   	rxe_add_ref(pkt->qp);
> >   	atomic_inc(&pkt->qp->skb_out);
> > -	if (av->network_type == RDMA_NETWORK_IPV4) {
> > +	if (skb->protocol == htons(ETH_P_IP)) {
> >   		err = ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
> > -	} else if (av->network_type == RDMA_NETWORK_IPV6) {
> > +	} else if (skb->protocol == htons(ETH_P_IPV6)) {
> >   		err = ip6_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
> >   	} else {
> > -		pr_err("Unknown layer 3 protocol: %d\n", av->network_type);
> > +		pr_err("Unknown layer 3 protocol: %d\n", skb->protocol);
> >   		atomic_dec(&pkt->qp->skb_out);
> >   		rxe_drop_ref(pkt->qp);
> >   		kfree_skb(skb);
Jason Gunthorpe March 26, 2019, 3:06 p.m. UTC | #3
On Sun, Feb 24, 2019 at 06:26:46AM -0500, Zhu Yanjun wrote:
> In the function rxe_init_packet, based on av->network_type,
> skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
> and rxe_send are called after the functin rxe_init_packet.
> So in these functions, av->network_type can be replaced with
> skb->protocol.
> The functions are in the xmit fast path. So with skb->protocol,
> the performance will be better.
> 
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)

It doesn't compile, please rebase and resend:

drivers/infiniband/sw/rxe/rxe_net.c: In function ‘rxe_prepare’:
drivers/infiniband/sw/rxe/rxe_net.c:403:43: error: ‘av’ undeclared (first use in this function)
  if (ether_addr_equal(skb->dev->dev_addr, av->dmac))
                                           ^~

Jason
Zhu Yanjun March 27, 2019, 1:08 a.m. UTC | #4
On 2019/3/26 23:06, Jason Gunthorpe wrote:
> On Sun, Feb 24, 2019 at 06:26:46AM -0500, Zhu Yanjun wrote:
>> In the function rxe_init_packet, based on av->network_type,
>> skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
>> and rxe_send are called after the functin rxe_init_packet.
>> So in these functions, av->network_type can be replaced with
>> skb->protocol.
>> The functions are in the xmit fast path. So with skb->protocol,
>> the performance will be better.
>>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>> ---
>>   drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
>>   1 file changed, 11 insertions(+), 15 deletions(-)
> It doesn't compile, please rebase and resend:
>
> drivers/infiniband/sw/rxe/rxe_net.c: In function ‘rxe_prepare’:
> drivers/infiniband/sw/rxe/rxe_net.c:403:43: error: ‘av’ undeclared (first use in this function)
>    if (ether_addr_equal(skb->dev->dev_addr, av->dmac))

OK. I will resend a new patch ASAP. Please wait.

Zhu Yanjun

>                                             ^~
>
> Jason
Zhu Yanjun March 27, 2019, 9:52 a.m. UTC | #5
On 2019/3/27 9:08, Yanjun Zhu wrote:
>
> On 2019/3/26 23:06, Jason Gunthorpe wrote:
>> On Sun, Feb 24, 2019 at 06:26:46AM -0500, Zhu Yanjun wrote:
>>> In the function rxe_init_packet, based on av->network_type,
>>> skb->protocol is set to ipv4 or ipv6. The functions rxe_prepare
>>> and rxe_send are called after the functin rxe_init_packet.
>>> So in these functions, av->network_type can be replaced with
>>> skb->protocol.
>>> The functions are in the xmit fast path. So with skb->protocol,
>>> the performance will be better.
>>>
>>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>>> ---
>>>   drivers/infiniband/sw/rxe/rxe_net.c | 26 +++++++++++---------------
>>>   1 file changed, 11 insertions(+), 15 deletions(-)
>> It doesn't compile, please rebase and resend:
>>
>> drivers/infiniband/sw/rxe/rxe_net.c: In function ‘rxe_prepare’:
>> drivers/infiniband/sw/rxe/rxe_net.c:403:43: error: ‘av’ undeclared 
>> (first use in this function)
>>    if (ether_addr_equal(skb->dev->dev_addr, av->dmac))
>
> OK. I will resend a new patch ASAP. Please wait.

Hi, Jason

The new patch is sent. Please check it. The new patch is based on 
rdma.git. And I made simple test.

It can pass compile. If anything, please let me know as soon as possible.

Zhu Yanjun

>
> Zhu Yanjun
>
>> ^~
>>
>> Jason
>
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 8fd03ae..edac208 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -368,13 +368,13 @@  static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb,
 	ip6h->payload_len = htons(skb->len - sizeof(*ip6h));
 }
 
-static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
-		    struct rxe_av *av)
+static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 {
 	struct rxe_qp *qp = pkt->qp;
 	struct dst_entry *dst;
 	bool xnet = false;
 	__be16 df = htons(IP_DF);
+	struct rxe_av *av = rxe_get_av(pkt);
 	struct in_addr *saddr = &av->sgid_addr._sockaddr_in.sin_addr;
 	struct in_addr *daddr = &av->dgid_addr._sockaddr_in.sin_addr;
 
@@ -397,11 +397,11 @@  static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
 	return 0;
 }
 
-static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
-		    struct rxe_av *av)
+static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 {
 	struct rxe_qp *qp = pkt->qp;
 	struct dst_entry *dst;
+	struct rxe_av *av = rxe_get_av(pkt);
 	struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
 	struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
 
@@ -428,12 +428,11 @@  static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
 int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb, u32 *crc)
 {
 	int err = 0;
-	struct rxe_av *av = rxe_get_av(pkt);
 
-	if (av->network_type == RDMA_NETWORK_IPV4)
-		err = prepare4(pkt, skb, av);
-	else if (av->network_type == RDMA_NETWORK_IPV6)
-		err = prepare6(pkt, skb, av);
+	if (skb->protocol == htons(ETH_P_IP))
+		err = prepare4(pkt, skb);
+	else if (skb->protocol == htons(ETH_P_IPV6))
+		err = prepare6(pkt, skb);
 
 	*crc = rxe_icrc_hdr(pkt, skb);
 
@@ -455,23 +454,20 @@  static void rxe_skb_tx_dtor(struct sk_buff *skb)
 
 int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb)
 {
-	struct rxe_av *av;
 	int err;
 
-	av = rxe_get_av(pkt);
-
 	skb->destructor = rxe_skb_tx_dtor;
 	skb->sk = pkt->qp->sk->sk;
 
 	rxe_add_ref(pkt->qp);
 	atomic_inc(&pkt->qp->skb_out);
 
-	if (av->network_type == RDMA_NETWORK_IPV4) {
+	if (skb->protocol == htons(ETH_P_IP)) {
 		err = ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
-	} else if (av->network_type == RDMA_NETWORK_IPV6) {
+	} else if (skb->protocol == htons(ETH_P_IPV6)) {
 		err = ip6_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb);
 	} else {
-		pr_err("Unknown layer 3 protocol: %d\n", av->network_type);
+		pr_err("Unknown layer 3 protocol: %d\n", skb->protocol);
 		atomic_dec(&pkt->qp->skb_out);
 		rxe_drop_ref(pkt->qp);
 		kfree_skb(skb);