RDMA/rxe: Improve loopback marking
authorKamal Heib <kamalheib1@gmail.com>
Tue, 29 Jan 2019 10:08:50 +0000 (12:08 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 4 Feb 2019 22:57:49 +0000 (15:57 -0700)
Currently a packet is marked for loopback only if the source and
destination addresses equals. This is not enough when multiple gids are
present in rxe device's gid table and the traffic is from one gid to
another. Fix it by marking the packet for loopback if the destination MAC
address is equal to the source MAC address.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Tested-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/sw/rxe/rxe_av.c
drivers/infiniband/sw/rxe/rxe_net.c
include/uapi/rdma/rdma_user_rxe.h

index 27a7dec18874d126f59b70f1c77e847e59e376f8..81ee756c19b8793772725dbb66e4710069bb7120 100644 (file)
@@ -38,6 +38,7 @@ void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av)
 {
        rxe_av_from_attr(rdma_ah_get_port_num(attr), av, attr);
        rxe_av_fill_ip_info(av, attr);
+       memcpy(av->dmac, attr->roce.dmac, ETH_ALEN);
 }
 
 int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr)
index 19f3c69916b19aef77c4d621a919490d2c6c9446..3b162e92e8e8d72178c257b4ced7cd1cb771a145 100644 (file)
@@ -384,9 +384,6 @@ static int prepare4(struct rxe_pkt_info *pkt, struct sk_buff *skb,
                return -EHOSTUNREACH;
        }
 
-       if (!memcmp(saddr, daddr, sizeof(*daddr)))
-               pkt->mask |= RXE_LOOPBACK_MASK;
-
        prepare_udp_hdr(skb, cpu_to_be16(qp->src_port),
                        cpu_to_be16(ROCE_V2_UDP_DPORT));
 
@@ -411,9 +408,6 @@ static int prepare6(struct rxe_pkt_info *pkt, struct sk_buff *skb,
                return -EHOSTUNREACH;
        }
 
-       if (!memcmp(saddr, daddr, sizeof(*daddr)))
-               pkt->mask |= RXE_LOOPBACK_MASK;
-
        prepare_udp_hdr(skb, cpu_to_be16(qp->src_port),
                        cpu_to_be16(ROCE_V2_UDP_DPORT));
 
@@ -437,6 +431,9 @@ int rxe_prepare(struct rxe_pkt_info *pkt, struct sk_buff *skb, u32 *crc)
 
        *crc = rxe_icrc_hdr(pkt, skb);
 
+       if (ether_addr_equal(skb->dev->dev_addr, av->dmac))
+               pkt->mask |= RXE_LOOPBACK_MASK;
+
        return err;
 }
 
index 44ef6a3b7afc8ce4269d2e363482803be42ed379..aae2e696bb381eacbeaf15bc16e3eda36b5c355d 100644 (file)
@@ -58,8 +58,7 @@ struct rxe_global_route {
 struct rxe_av {
        __u8                    port_num;
        __u8                    network_type;
-       __u16                   reserved1;
-       __u32                   reserved2;
+       __u8                    dmac[6];
        struct rxe_global_route grh;
        union {
                struct sockaddr_in      _sockaddr_in;