RDMA/hns: Add enable judgement for UD vlan
authorLijun Ou <oulijun@huawei.com>
Sat, 22 Sep 2018 08:21:08 +0000 (16:21 +0800)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 26 Sep 2018 20:59:13 +0000 (14:59 -0600)
According to the hardware modification, the vlan of the UD packet is based
on the ud_vlan_en field of the UD wqe to determine whether to add a vlan
header to the UD packet. The ud_vlan_en field is filled by the driver
according to the net device.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hns/hns_roce_ah.c
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.h

index 0d96c5bb38cdf5bc066a1caf8bb0f2e28d1a7892..9990dc9eb96a14803be2633115af9b70863e0353 100644 (file)
@@ -49,6 +49,7 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
        struct hns_roce_ah *ah;
        u16 vlan_tag = 0xffff;
        const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
+       bool vlan_en = false;
 
        ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
        if (!ah)
@@ -58,8 +59,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
        memcpy(ah->av.mac, ah_attr->roce.dmac, ETH_ALEN);
 
        gid_attr = ah_attr->grh.sgid_attr;
-       if (is_vlan_dev(gid_attr->ndev))
+       if (is_vlan_dev(gid_attr->ndev)) {
                vlan_tag = vlan_dev_vlan_id(gid_attr->ndev);
+               vlan_en = true;
+       }
 
        if (vlan_tag < 0x1000)
                vlan_tag |= (rdma_ah_get_sl(ah_attr) &
@@ -71,6 +74,7 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
                                     HNS_ROCE_PORT_NUM_SHIFT));
        ah->av.gid_index = grh->sgid_index;
        ah->av.vlan = cpu_to_le16(vlan_tag);
+       ah->av.vlan_en = vlan_en;
        dev_dbg(dev, "gid_index = 0x%x,vlan = 0x%x\n", ah->av.gid_index,
                ah->av.vlan);
 
index 7a2c0ca793f282417b2fafeb3afa11c7c9e65fe8..3b06bd03b852f6f59fe586bb772f1861bbafd167 100644 (file)
@@ -450,6 +450,7 @@ struct hns_roce_av {
        u8          dgid[HNS_ROCE_GID_SIZE];
        u8          mac[6];
        __le16      vlan;
+       bool        vlan_en;
 };
 
 struct hns_roce_ah {
index a781f6b49782fbb27be72ee5ddd3c23ef8335a39..3b52d56d56f6b4b2f7787ee553a1fa4c869572d3 100644 (file)
@@ -370,6 +370,9 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp,
                                       V2_UD_SEND_WQE_BYTE_40_PORTN_S,
                                       qp->port);
 
+                       roce_set_bit(ud_sq_wqe->byte_40,
+                                    V2_UD_SEND_WQE_BYTE_40_UD_VLAN_EN_S,
+                                    ah->av.vlan_en ? 1 : 0);
                        roce_set_field(ud_sq_wqe->byte_48,
                                       V2_UD_SEND_WQE_BYTE_48_SGID_INDX_M,
                                       V2_UD_SEND_WQE_BYTE_48_SGID_INDX_S,
index d04be1cef4539c781ed52c493d45639844f05b12..7ee6ed276fa68d0e5e754e7971b585b6cb67f721 100644 (file)
@@ -993,6 +993,8 @@ struct hns_roce_v2_ud_send_wqe {
 #define        V2_UD_SEND_WQE_BYTE_40_PORTN_S 24
 #define V2_UD_SEND_WQE_BYTE_40_PORTN_M GENMASK(26, 24)
 
+#define V2_UD_SEND_WQE_BYTE_40_UD_VLAN_EN_S 30
+
 #define        V2_UD_SEND_WQE_BYTE_40_LBI_S 31
 
 #define        V2_UD_SEND_WQE_DMAC_0_S 0