]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ofed/libibverbs/fixes/rocee_get_mac.patch
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ofed / libibverbs / fixes / rocee_get_mac.patch
1 [PATCHv7 3/4] libibverbs: Add API to retrieve eth MAC
2
3 Add a command to retrieve the MAC address of a port's GID. This is required by
4 libraries to build work requests when the port's link layer is Ethernet.
5
6 Signed-off-by: Eli Cohen <eli@mellanox.co.il>
7 ---
8  include/infiniband/driver.h   |    1 +
9  include/infiniband/kern-abi.h |   20 +++++++++++++++++++-
10  src/cmd.c                     |   19 +++++++++++++++++++
11  src/libibverbs.map            |    1 +
12  4 files changed, 40 insertions(+), 1 deletions(-)
13
14 Index: libibverbs/include/infiniband/driver.h
15 ===================================================================
16 --- libibverbs.orig/include/infiniband/driver.h 2010-02-18 13:48:37.000000000 +0200
17 +++ libibverbs/include/infiniband/driver.h      2010-02-18 13:50:53.000000000 +0200
18 @@ -136,6 +136,11 @@ int ibv_cmd_create_ah(struct ibv_pd *pd,
19  int ibv_cmd_destroy_ah(struct ibv_ah *ah);
20  int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
21  int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
22 +int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
23 +                           int sgid_idx, uint8_t *mac, uint16_t *vlan_id);
24 +
25 +int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
26 +                            int sgid_idx, uint8_t *mac, uint16_t *vlan_id);
27  
28  int ibv_dontfork_range(void *base, size_t size);
29  int ibv_dofork_range(void *base, size_t size);
30 Index: libibverbs/include/infiniband/kern-abi.h
31 ===================================================================
32 --- libibverbs.orig/include/infiniband/kern-abi.h       2010-02-18 13:48:46.000000000 +0200
33 +++ libibverbs/include/infiniband/kern-abi.h    2010-02-18 13:50:53.000000000 +0200
34 @@ -94,6 +94,7 @@ enum {
35         IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
36         IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
37         IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
38 +       IB_USER_VERBS_CMD_GET_ETH_L2_ADDR,
39  };
40  
41  /*
42 @@ -946,6 +947,7 @@ enum {
43         IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
44         IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
45         IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
46 +       IB_USER_VERBS_CMD_GET_ETH_L2_ADDR_V2 = -1,
47  };
48  
49  struct ibv_destroy_cq_v1 {
50 @@ -1021,4 +1023,21 @@ struct ibv_create_srq_resp_v5 {
51         __u32 srq_handle;
52  };
53  
54 +struct ibv_get_eth_l2_addr {
55 +        __u32 command;
56 +        __u16 in_words;
57 +        __u16 out_words;
58 +        __u64 response;
59 +        __u32 pd_handle;
60 +        __u8  port;
61 +        __u8  sgid_idx;
62 +        __u8  reserved[2];
63 +        __u8  dgid[16];
64 +};
65 +
66 +struct ibv_get_eth_l2_addr_resp {
67 +        __u8    mac[6];
68 +        __u16   vlan_id;
69 +};
70 +
71  #endif /* KERN_ABI_H */
72 Index: libibverbs/src/cmd.c
73 ===================================================================
74 --- libibverbs.orig/src/cmd.c   2010-02-18 13:48:46.000000000 +0200
75 +++ libibverbs/src/cmd.c        2010-02-18 13:50:53.000000000 +0200
76 @@ -1407,4 +1407,24 @@ int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_
77         return 0;
78  }
79  
80 +int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
81 +                            int sgid_idx, uint8_t *mac, uint16_t *vlan_id)
82 +{
83 +        struct ibv_get_eth_l2_addr cmd;
84 +        struct ibv_get_eth_l2_addr_resp resp;
85 +
86 +        IBV_INIT_CMD_RESP(&cmd, sizeof cmd, GET_ETH_L2_ADDR, &resp, sizeof resp);
87 +        memcpy(cmd.dgid, gid, sizeof cmd.dgid);
88 +        cmd.pd_handle = pd->handle;
89 +        cmd.port = port;
90 +        cmd.sgid_idx = sgid_idx;
91 +
92 +        if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
93 +                return errno;
94 +
95 +        memcpy(mac, resp.mac, 6);
96 +        *vlan_id = resp.vlan_id;
97 +
98 +        return 0;
99 +}
100  
101 Index: libibverbs/src/libibverbs.map
102 ===================================================================
103 --- libibverbs.orig/src/libibverbs.map  2010-02-18 13:48:37.000000000 +0200
104 +++ libibverbs/src/libibverbs.map       2010-02-18 13:50:53.000000000 +0200
105 @@ -64,6 +64,7 @@ IBVERBS_1.0 {
106                 ibv_cmd_destroy_ah;
107                 ibv_cmd_attach_mcast;
108                 ibv_cmd_detach_mcast;
109 +               ibv_cmd_get_eth_l2_addr;
110                 ibv_copy_qp_attr_from_kern;
111                 ibv_copy_path_rec_from_kern;
112                 ibv_copy_path_rec_to_kern;