1219820Sjeff[PATCHv7 3/4] libibverbs: Add API to retrieve eth MAC 2219820Sjeff 3219820SjeffAdd a command to retrieve the MAC address of a port's GID. This is required by 4219820Sjefflibraries to build work requests when the port's link layer is Ethernet. 5219820Sjeff 6219820SjeffSigned-off-by: Eli Cohen <eli@mellanox.co.il> 7219820Sjeff--- 8219820Sjeff include/infiniband/driver.h | 1 + 9219820Sjeff include/infiniband/kern-abi.h | 20 +++++++++++++++++++- 10219820Sjeff src/cmd.c | 19 +++++++++++++++++++ 11219820Sjeff src/libibverbs.map | 1 + 12219820Sjeff 4 files changed, 40 insertions(+), 1 deletions(-) 13219820Sjeff 14219820SjeffIndex: libibverbs/include/infiniband/driver.h 15219820Sjeff=================================================================== 16219820Sjeff--- libibverbs.orig/include/infiniband/driver.h 2010-02-18 13:48:37.000000000 +0200 17219820Sjeff+++ libibverbs/include/infiniband/driver.h 2010-02-18 13:50:53.000000000 +0200 18219820Sjeff@@ -136,6 +136,11 @@ int ibv_cmd_create_ah(struct ibv_pd *pd, 19219820Sjeff int ibv_cmd_destroy_ah(struct ibv_ah *ah); 20219820Sjeff int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); 21219820Sjeff int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid); 22219820Sjeff+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid, 23219820Sjeff+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id); 24219820Sjeff+ 25219820Sjeff+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid, 26219820Sjeff+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id); 27219820Sjeff 28219820Sjeff int ibv_dontfork_range(void *base, size_t size); 29219820Sjeff int ibv_dofork_range(void *base, size_t size); 30219820SjeffIndex: libibverbs/include/infiniband/kern-abi.h 31219820Sjeff=================================================================== 32219820Sjeff--- libibverbs.orig/include/infiniband/kern-abi.h 2010-02-18 13:48:46.000000000 +0200 33219820Sjeff+++ libibverbs/include/infiniband/kern-abi.h 2010-02-18 13:50:53.000000000 +0200 34219820Sjeff@@ -94,6 +94,7 @@ enum { 35219820Sjeff IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP, 36219820Sjeff IB_USER_VERBS_CMD_REG_XRC_RCV_QP, 37219820Sjeff IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP, 38219820Sjeff+ IB_USER_VERBS_CMD_GET_ETH_L2_ADDR, 39219820Sjeff }; 40219820Sjeff 41219820Sjeff /* 42219820Sjeff@@ -946,6 +947,7 @@ enum { 43219820Sjeff IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1, 44219820Sjeff IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1, 45219820Sjeff IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1, 46219820Sjeff+ IB_USER_VERBS_CMD_GET_ETH_L2_ADDR_V2 = -1, 47219820Sjeff }; 48219820Sjeff 49219820Sjeff struct ibv_destroy_cq_v1 { 50219820Sjeff@@ -1021,4 +1023,21 @@ struct ibv_create_srq_resp_v5 { 51219820Sjeff __u32 srq_handle; 52219820Sjeff }; 53219820Sjeff 54219820Sjeff+struct ibv_get_eth_l2_addr { 55219820Sjeff+ __u32 command; 56219820Sjeff+ __u16 in_words; 57219820Sjeff+ __u16 out_words; 58219820Sjeff+ __u64 response; 59219820Sjeff+ __u32 pd_handle; 60219820Sjeff+ __u8 port; 61219820Sjeff+ __u8 sgid_idx; 62219820Sjeff+ __u8 reserved[2]; 63219820Sjeff+ __u8 dgid[16]; 64219820Sjeff+}; 65219820Sjeff+ 66219820Sjeff+struct ibv_get_eth_l2_addr_resp { 67219820Sjeff+ __u8 mac[6]; 68219820Sjeff+ __u16 vlan_id; 69219820Sjeff+}; 70219820Sjeff+ 71219820Sjeff #endif /* KERN_ABI_H */ 72219820SjeffIndex: libibverbs/src/cmd.c 73219820Sjeff=================================================================== 74219820Sjeff--- libibverbs.orig/src/cmd.c 2010-02-18 13:48:46.000000000 +0200 75219820Sjeff+++ libibverbs/src/cmd.c 2010-02-18 13:50:53.000000000 +0200 76219820Sjeff@@ -1407,4 +1407,24 @@ int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_ 77219820Sjeff return 0; 78219820Sjeff } 79219820Sjeff 80219820Sjeff+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid, 81219820Sjeff+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id) 82219820Sjeff+{ 83219820Sjeff+ struct ibv_get_eth_l2_addr cmd; 84219820Sjeff+ struct ibv_get_eth_l2_addr_resp resp; 85219820Sjeff+ 86219820Sjeff+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, GET_ETH_L2_ADDR, &resp, sizeof resp); 87219820Sjeff+ memcpy(cmd.dgid, gid, sizeof cmd.dgid); 88219820Sjeff+ cmd.pd_handle = pd->handle; 89219820Sjeff+ cmd.port = port; 90219820Sjeff+ cmd.sgid_idx = sgid_idx; 91219820Sjeff+ 92219820Sjeff+ if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) 93219820Sjeff+ return errno; 94219820Sjeff+ 95219820Sjeff+ memcpy(mac, resp.mac, 6); 96219820Sjeff+ *vlan_id = resp.vlan_id; 97219820Sjeff+ 98219820Sjeff+ return 0; 99219820Sjeff+} 100219820Sjeff 101219820SjeffIndex: libibverbs/src/libibverbs.map 102219820Sjeff=================================================================== 103219820Sjeff--- libibverbs.orig/src/libibverbs.map 2010-02-18 13:48:37.000000000 +0200 104219820Sjeff+++ libibverbs/src/libibverbs.map 2010-02-18 13:50:53.000000000 +0200 105219820Sjeff@@ -64,6 +64,7 @@ IBVERBS_1.0 { 106219820Sjeff ibv_cmd_destroy_ah; 107219820Sjeff ibv_cmd_attach_mcast; 108219820Sjeff ibv_cmd_detach_mcast; 109219820Sjeff+ ibv_cmd_get_eth_l2_addr; 110219820Sjeff ibv_copy_qp_attr_from_kern; 111219820Sjeff ibv_copy_path_rec_from_kern; 112219820Sjeff ibv_copy_path_rec_to_kern; 113