1 [PATCHv7 3/4] libibverbs: Add API to retrieve eth MAC
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.
6 Signed-off-by: Eli Cohen <eli@mellanox.co.il>
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(-)
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);
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);
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,
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,
49 struct ibv_destroy_cq_v1 {
50 @@ -1021,4 +1023,21 @@ struct ibv_create_srq_resp_v5 {
54 +struct ibv_get_eth_l2_addr {
66 +struct ibv_get_eth_l2_addr_resp {
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_
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)
83 + struct ibv_get_eth_l2_addr cmd;
84 + struct ibv_get_eth_l2_addr_resp resp;
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;
90 + cmd.sgid_idx = sgid_idx;
92 + if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
95 + memcpy(mac, resp.mac, 6);
96 + *vlan_id = resp.vlan_id;
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 {
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;