aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorMatan Barak <matanb@mellanox.com>2013-12-12 11:03:11 -0500
committerRoland Dreier <roland@purestorage.com>2014-01-14 17:20:54 -0500
commitdd5f03beb4f76ae65d76d8c22a8815e424fc607c (patch)
tree162cb1bece8602841de5cff1d37e781de8528c0f /include/rdma
parent7e22e91102c6b9df7c4ae2168910e19d2bb14cd6 (diff)
IB/core: Ethernet L2 attributes in verbs/cm structures
This patch add the support for Ethernet L2 attributes in the verbs/cm/cma structures. When dealing with L2 Ethernet, we should use smac, dmac, vlan ID and priority in a similar manner that the IB L2 (and the L4 PKEY) attributes are used. Thus, those attributes were added to the following structures: * ib_ah_attr - added dmac * ib_qp_attr - added smac and vlan_id, (sl remains vlan priority) * ib_wc - added smac, vlan_id * ib_sa_path_rec - added smac, dmac, vlan_id * cm_av - added smac and vlan_id For the path record structure, extra care was taken to avoid the new fields when packing it into wire format, so we don't break the IB CM and SA wire protocol. On the active side, the CM fills. its internal structures from the path provided by the ULP. We add there taking the ETH L2 attributes and placing them into the CM Address Handle (struct cm_av). On the passive side, the CM fills its internal structures from the WC associated with the REQ message. We add there taking the ETH L2 attributes from the WC. When the HW driver provides the required ETH L2 attributes in the WC, they set the IB_WC_WITH_SMAC and IB_WC_WITH_VLAN flags. The IB core code checks for the presence of these flags, and in their absence does address resolution from the ib_init_ah_from_wc() helper function. ib_modify_qp_is_ok is also updated to consider the link layer. Some parameters are mandatory for Ethernet link layer, while they are irrelevant for IB. Vendor drivers are modified to support the new function signature. Signed-off-by: Matan Barak <matanb@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_addr.h42
-rw-r--r--include/rdma/ib_cm.h1
-rw-r--r--include/rdma/ib_pack.h1
-rw-r--r--include/rdma/ib_sa.h3
-rw-r--r--include/rdma/ib_verbs.h21
5 files changed, 65 insertions, 3 deletions
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index f3ac0f2c4c66..a0715606ebb2 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -42,6 +42,7 @@
42#include <linux/if_vlan.h> 42#include <linux/if_vlan.h>
43#include <rdma/ib_verbs.h> 43#include <rdma/ib_verbs.h>
44#include <rdma/ib_pack.h> 44#include <rdma/ib_pack.h>
45#include <net/ipv6.h>
45 46
46struct rdma_addr_client { 47struct rdma_addr_client {
47 atomic_t refcount; 48 atomic_t refcount;
@@ -72,7 +73,8 @@ struct rdma_dev_addr {
72 * rdma_translate_ip - Translate a local IP address to an RDMA hardware 73 * rdma_translate_ip - Translate a local IP address to an RDMA hardware
73 * address. 74 * address.
74 */ 75 */
75int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr); 76int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
77 u16 *vlan_id);
76 78
77/** 79/**
78 * rdma_resolve_ip - Resolve source and destination IP addresses to 80 * rdma_resolve_ip - Resolve source and destination IP addresses to
@@ -104,6 +106,10 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
104 106
105int rdma_addr_size(struct sockaddr *addr); 107int rdma_addr_size(struct sockaddr *addr);
106 108
109int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id);
110int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *smac,
111 u16 *vlan_id);
112
107static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr) 113static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
108{ 114{
109 return ((u16)dev_addr->broadcast[8] << 8) | (u16)dev_addr->broadcast[9]; 115 return ((u16)dev_addr->broadcast[8] << 8) | (u16)dev_addr->broadcast[9];
@@ -142,6 +148,40 @@ static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid)
142 gid->raw[8] ^= 2; 148 gid->raw[8] ^= 2;
143} 149}
144 150
151static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
152{
153 switch (addr->sa_family) {
154 case AF_INET:
155 ipv6_addr_set_v4mapped(((struct sockaddr_in *)
156 addr)->sin_addr.s_addr,
157 (struct in6_addr *)gid);
158 break;
159 case AF_INET6:
160 memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16);
161 break;
162 default:
163 return -EINVAL;
164 }
165 return 0;
166}
167
168/* Important - sockaddr should be a union of sockaddr_in and sockaddr_in6 */
169static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid)
170{
171 if (ipv6_addr_v4mapped((struct in6_addr *)gid)) {
172 struct sockaddr_in *out_in = (struct sockaddr_in *)out;
173 memset(out_in, 0, sizeof(*out_in));
174 out_in->sin_family = AF_INET;
175 memcpy(&out_in->sin_addr.s_addr, gid->raw + 12, 4);
176 } else {
177 struct sockaddr_in6 *out_in = (struct sockaddr_in6 *)out;
178 memset(out_in, 0, sizeof(*out_in));
179 out_in->sin6_family = AF_INET6;
180 memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16);
181 }
182 return 0;
183}
184
145static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) 185static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
146{ 186{
147 return dev->priv_flags & IFF_802_1Q_VLAN ? 187 return dev->priv_flags & IFF_802_1Q_VLAN ?
diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
index 0e3ff30647d5..f29e3a27c2cc 100644
--- a/include/rdma/ib_cm.h
+++ b/include/rdma/ib_cm.h
@@ -601,4 +601,5 @@ struct ib_cm_sidr_rep_param {
601int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id, 601int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
602 struct ib_cm_sidr_rep_param *param); 602 struct ib_cm_sidr_rep_param *param);
603 603
604int ib_update_cm_av(struct ib_cm_id *id, const u8 *smac, const u8 *alt_smac);
604#endif /* IB_CM_H */ 605#endif /* IB_CM_H */
diff --git a/include/rdma/ib_pack.h b/include/rdma/ib_pack.h
index b37fe3b10a9d..b1f7592e02e4 100644
--- a/include/rdma/ib_pack.h
+++ b/include/rdma/ib_pack.h
@@ -34,6 +34,7 @@
34#define IB_PACK_H 34#define IB_PACK_H
35 35
36#include <rdma/ib_verbs.h> 36#include <rdma/ib_verbs.h>
37#include <uapi/linux/if_ether.h>
37 38
38enum { 39enum {
39 IB_LRH_BYTES = 8, 40 IB_LRH_BYTES = 8,
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 125f8714301d..7e071a6abb34 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -154,6 +154,9 @@ struct ib_sa_path_rec {
154 u8 packet_life_time_selector; 154 u8 packet_life_time_selector;
155 u8 packet_life_time; 155 u8 packet_life_time;
156 u8 preference; 156 u8 preference;
157 u8 smac[ETH_ALEN];
158 u8 dmac[ETH_ALEN];
159 u16 vlan_id;
157}; 160};
158 161
159#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0) 162#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 61e1935c91b1..ea0f6eed7863 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -48,6 +48,7 @@
48#include <linux/rwsem.h> 48#include <linux/rwsem.h>
49#include <linux/scatterlist.h> 49#include <linux/scatterlist.h>
50#include <linux/workqueue.h> 50#include <linux/workqueue.h>
51#include <uapi/linux/if_ether.h>
51 52
52#include <linux/atomic.h> 53#include <linux/atomic.h>
53#include <asm/uaccess.h> 54#include <asm/uaccess.h>
@@ -472,6 +473,8 @@ struct ib_ah_attr {
472 u8 static_rate; 473 u8 static_rate;
473 u8 ah_flags; 474 u8 ah_flags;
474 u8 port_num; 475 u8 port_num;
476 u8 dmac[ETH_ALEN];
477 u16 vlan_id;
475}; 478};
476 479
477enum ib_wc_status { 480enum ib_wc_status {
@@ -524,6 +527,8 @@ enum ib_wc_flags {
524 IB_WC_WITH_IMM = (1<<1), 527 IB_WC_WITH_IMM = (1<<1),
525 IB_WC_WITH_INVALIDATE = (1<<2), 528 IB_WC_WITH_INVALIDATE = (1<<2),
526 IB_WC_IP_CSUM_OK = (1<<3), 529 IB_WC_IP_CSUM_OK = (1<<3),
530 IB_WC_WITH_SMAC = (1<<4),
531 IB_WC_WITH_VLAN = (1<<5),
527}; 532};
528 533
529struct ib_wc { 534struct ib_wc {
@@ -544,6 +549,8 @@ struct ib_wc {
544 u8 sl; 549 u8 sl;
545 u8 dlid_path_bits; 550 u8 dlid_path_bits;
546 u8 port_num; /* valid only for DR SMPs on switches */ 551 u8 port_num; /* valid only for DR SMPs on switches */
552 u8 smac[ETH_ALEN];
553 u16 vlan_id;
547}; 554};
548 555
549enum ib_cq_notify_flags { 556enum ib_cq_notify_flags {
@@ -721,7 +728,11 @@ enum ib_qp_attr_mask {
721 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), 728 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
722 IB_QP_PATH_MIG_STATE = (1<<18), 729 IB_QP_PATH_MIG_STATE = (1<<18),
723 IB_QP_CAP = (1<<19), 730 IB_QP_CAP = (1<<19),
724 IB_QP_DEST_QPN = (1<<20) 731 IB_QP_DEST_QPN = (1<<20),
732 IB_QP_SMAC = (1<<21),
733 IB_QP_ALT_SMAC = (1<<22),
734 IB_QP_VID = (1<<23),
735 IB_QP_ALT_VID = (1<<24),
725}; 736};
726 737
727enum ib_qp_state { 738enum ib_qp_state {
@@ -771,6 +782,10 @@ struct ib_qp_attr {
771 u8 rnr_retry; 782 u8 rnr_retry;
772 u8 alt_port_num; 783 u8 alt_port_num;
773 u8 alt_timeout; 784 u8 alt_timeout;
785 u8 smac[ETH_ALEN];
786 u8 alt_smac[ETH_ALEN];
787 u16 vlan_id;
788 u16 alt_vlan_id;
774}; 789};
775 790
776enum ib_wr_opcode { 791enum ib_wr_opcode {
@@ -1488,6 +1503,7 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len
1488 * @next_state: Next QP state 1503 * @next_state: Next QP state
1489 * @type: QP type 1504 * @type: QP type
1490 * @mask: Mask of supplied QP attributes 1505 * @mask: Mask of supplied QP attributes
1506 * @ll : link layer of port
1491 * 1507 *
1492 * This function is a helper function that a low-level driver's 1508 * This function is a helper function that a low-level driver's
1493 * modify_qp method can use to validate the consumer's input. It 1509 * modify_qp method can use to validate the consumer's input. It
@@ -1496,7 +1512,8 @@ static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len
1496 * and that the attribute mask supplied is allowed for the transition. 1512 * and that the attribute mask supplied is allowed for the transition.
1497 */ 1513 */
1498int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, 1514int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
1499 enum ib_qp_type type, enum ib_qp_attr_mask mask); 1515 enum ib_qp_type type, enum ib_qp_attr_mask mask,
1516 enum rdma_link_layer ll);
1500 1517
1501int ib_register_event_handler (struct ib_event_handler *event_handler); 1518int ib_register_event_handler (struct ib_event_handler *event_handler);
1502int ib_unregister_event_handler(struct ib_event_handler *event_handler); 1519int ib_unregister_event_handler(struct ib_event_handler *event_handler);