0001
0002
0003
0004
0005
0006
0007
0008 #ifndef IB_SA_H
0009 #define IB_SA_H
0010
0011 #include <linux/completion.h>
0012 #include <linux/compiler.h>
0013
0014 #include <linux/atomic.h>
0015 #include <linux/netdevice.h>
0016
0017 #include <rdma/ib_verbs.h>
0018 #include <rdma/ib_mad.h>
0019 #include <rdma/ib_addr.h>
0020 #include <rdma/opa_addr.h>
0021
0022 enum {
0023 IB_SA_CLASS_VERSION = 2,
0024
0025 IB_SA_METHOD_GET_TABLE = 0x12,
0026 IB_SA_METHOD_GET_TABLE_RESP = 0x92,
0027 IB_SA_METHOD_DELETE = 0x15,
0028 IB_SA_METHOD_DELETE_RESP = 0x95,
0029 IB_SA_METHOD_GET_MULTI = 0x14,
0030 IB_SA_METHOD_GET_MULTI_RESP = 0x94,
0031 IB_SA_METHOD_GET_TRACE_TBL = 0x13
0032 };
0033
0034 #define OPA_SA_CLASS_VERSION 0x80
0035 enum {
0036 IB_SA_ATTR_CLASS_PORTINFO = 0x01,
0037 IB_SA_ATTR_NOTICE = 0x02,
0038 IB_SA_ATTR_INFORM_INFO = 0x03,
0039 IB_SA_ATTR_NODE_REC = 0x11,
0040 IB_SA_ATTR_PORT_INFO_REC = 0x12,
0041 IB_SA_ATTR_SL2VL_REC = 0x13,
0042 IB_SA_ATTR_SWITCH_REC = 0x14,
0043 IB_SA_ATTR_LINEAR_FDB_REC = 0x15,
0044 IB_SA_ATTR_RANDOM_FDB_REC = 0x16,
0045 IB_SA_ATTR_MCAST_FDB_REC = 0x17,
0046 IB_SA_ATTR_SM_INFO_REC = 0x18,
0047 IB_SA_ATTR_LINK_REC = 0x20,
0048 IB_SA_ATTR_GUID_INFO_REC = 0x30,
0049 IB_SA_ATTR_SERVICE_REC = 0x31,
0050 IB_SA_ATTR_PARTITION_REC = 0x33,
0051 IB_SA_ATTR_PATH_REC = 0x35,
0052 IB_SA_ATTR_VL_ARB_REC = 0x36,
0053 IB_SA_ATTR_MC_MEMBER_REC = 0x38,
0054 IB_SA_ATTR_TRACE_REC = 0x39,
0055 IB_SA_ATTR_MULTI_PATH_REC = 0x3a,
0056 IB_SA_ATTR_SERVICE_ASSOC_REC = 0x3b,
0057 IB_SA_ATTR_INFORM_INFO_REC = 0xf3
0058 };
0059
0060 enum ib_sa_selector {
0061 IB_SA_GT = 0,
0062 IB_SA_LT = 1,
0063 IB_SA_EQ = 2,
0064
0065
0066
0067
0068
0069
0070 IB_SA_BEST = 3
0071 };
0072
0073
0074
0075
0076
0077
0078 enum ib_sa_mc_join_states {
0079 FULLMEMBER_JOIN,
0080 NONMEMBER_JOIN,
0081 SENDONLY_NONMEBER_JOIN,
0082 SENDONLY_FULLMEMBER_JOIN,
0083 NUM_JOIN_MEMBERSHIP_TYPES,
0084 };
0085
0086 #define IB_SA_CAP_MASK2_SENDONLY_FULL_MEM_SUPPORT BIT(12)
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 #define IB_SA_PATH_REC_SERVICE_ID (IB_SA_COMP_MASK( 0) |\
0103 IB_SA_COMP_MASK( 1))
0104 #define IB_SA_PATH_REC_DGID IB_SA_COMP_MASK( 2)
0105 #define IB_SA_PATH_REC_SGID IB_SA_COMP_MASK( 3)
0106 #define IB_SA_PATH_REC_DLID IB_SA_COMP_MASK( 4)
0107 #define IB_SA_PATH_REC_SLID IB_SA_COMP_MASK( 5)
0108 #define IB_SA_PATH_REC_RAW_TRAFFIC IB_SA_COMP_MASK( 6)
0109
0110 #define IB_SA_PATH_REC_FLOW_LABEL IB_SA_COMP_MASK( 8)
0111 #define IB_SA_PATH_REC_HOP_LIMIT IB_SA_COMP_MASK( 9)
0112 #define IB_SA_PATH_REC_TRAFFIC_CLASS IB_SA_COMP_MASK(10)
0113 #define IB_SA_PATH_REC_REVERSIBLE IB_SA_COMP_MASK(11)
0114 #define IB_SA_PATH_REC_NUMB_PATH IB_SA_COMP_MASK(12)
0115 #define IB_SA_PATH_REC_PKEY IB_SA_COMP_MASK(13)
0116 #define IB_SA_PATH_REC_QOS_CLASS IB_SA_COMP_MASK(14)
0117 #define IB_SA_PATH_REC_SL IB_SA_COMP_MASK(15)
0118 #define IB_SA_PATH_REC_MTU_SELECTOR IB_SA_COMP_MASK(16)
0119 #define IB_SA_PATH_REC_MTU IB_SA_COMP_MASK(17)
0120 #define IB_SA_PATH_REC_RATE_SELECTOR IB_SA_COMP_MASK(18)
0121 #define IB_SA_PATH_REC_RATE IB_SA_COMP_MASK(19)
0122 #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20)
0123 #define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21)
0124 #define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22)
0125
0126 enum sa_path_rec_type {
0127 SA_PATH_REC_TYPE_IB,
0128 SA_PATH_REC_TYPE_ROCE_V1,
0129 SA_PATH_REC_TYPE_ROCE_V2,
0130 SA_PATH_REC_TYPE_OPA
0131 };
0132
0133 struct sa_path_rec_ib {
0134 __be16 dlid;
0135 __be16 slid;
0136 u8 raw_traffic;
0137 };
0138
0139
0140
0141
0142
0143
0144
0145
0146 struct sa_path_rec_roce {
0147 bool route_resolved;
0148 u8 dmac[ETH_ALEN];
0149 };
0150
0151 struct sa_path_rec_opa {
0152 __be32 dlid;
0153 __be32 slid;
0154 u8 raw_traffic;
0155 u8 l2_8B;
0156 u8 l2_10B;
0157 u8 l2_9B;
0158 u8 l2_16B;
0159 u8 qos_type;
0160 u8 qos_priority;
0161 };
0162
0163 struct sa_path_rec {
0164 union ib_gid dgid;
0165 union ib_gid sgid;
0166 __be64 service_id;
0167
0168 __be32 flow_label;
0169 u8 hop_limit;
0170 u8 traffic_class;
0171 u8 reversible;
0172 u8 numb_path;
0173 __be16 pkey;
0174 __be16 qos_class;
0175 u8 sl;
0176 u8 mtu_selector;
0177 u8 mtu;
0178 u8 rate_selector;
0179 u8 rate;
0180 u8 packet_life_time_selector;
0181 u8 packet_life_time;
0182 u8 preference;
0183 union {
0184 struct sa_path_rec_ib ib;
0185 struct sa_path_rec_roce roce;
0186 struct sa_path_rec_opa opa;
0187 };
0188 enum sa_path_rec_type rec_type;
0189 };
0190
0191 static inline enum ib_gid_type
0192 sa_conv_pathrec_to_gid_type(struct sa_path_rec *rec)
0193 {
0194 switch (rec->rec_type) {
0195 case SA_PATH_REC_TYPE_ROCE_V1:
0196 return IB_GID_TYPE_ROCE;
0197 case SA_PATH_REC_TYPE_ROCE_V2:
0198 return IB_GID_TYPE_ROCE_UDP_ENCAP;
0199 default:
0200 return IB_GID_TYPE_IB;
0201 }
0202 }
0203
0204 static inline enum sa_path_rec_type
0205 sa_conv_gid_to_pathrec_type(enum ib_gid_type type)
0206 {
0207 switch (type) {
0208 case IB_GID_TYPE_ROCE:
0209 return SA_PATH_REC_TYPE_ROCE_V1;
0210 case IB_GID_TYPE_ROCE_UDP_ENCAP:
0211 return SA_PATH_REC_TYPE_ROCE_V2;
0212 default:
0213 return SA_PATH_REC_TYPE_IB;
0214 }
0215 }
0216
0217 static inline void path_conv_opa_to_ib(struct sa_path_rec *ib,
0218 struct sa_path_rec *opa)
0219 {
0220 if ((be32_to_cpu(opa->opa.dlid) >=
0221 be16_to_cpu(IB_MULTICAST_LID_BASE)) ||
0222 (be32_to_cpu(opa->opa.slid) >=
0223 be16_to_cpu(IB_MULTICAST_LID_BASE))) {
0224
0225 ib->dgid.global.interface_id
0226 = OPA_MAKE_ID(be32_to_cpu(opa->opa.dlid));
0227 ib->dgid.global.subnet_prefix
0228 = opa->dgid.global.subnet_prefix;
0229 ib->sgid.global.interface_id
0230 = OPA_MAKE_ID(be32_to_cpu(opa->opa.slid));
0231 ib->dgid.global.subnet_prefix
0232 = opa->dgid.global.subnet_prefix;
0233 ib->ib.dlid = 0;
0234
0235 ib->ib.slid = 0;
0236 } else {
0237 ib->ib.dlid = htons(ntohl(opa->opa.dlid));
0238 ib->ib.slid = htons(ntohl(opa->opa.slid));
0239 }
0240 ib->service_id = opa->service_id;
0241 ib->ib.raw_traffic = opa->opa.raw_traffic;
0242 }
0243
0244 static inline void path_conv_ib_to_opa(struct sa_path_rec *opa,
0245 struct sa_path_rec *ib)
0246 {
0247 __be32 slid, dlid;
0248
0249 if ((ib_is_opa_gid(&ib->sgid)) ||
0250 (ib_is_opa_gid(&ib->dgid))) {
0251 slid = htonl(opa_get_lid_from_gid(&ib->sgid));
0252 dlid = htonl(opa_get_lid_from_gid(&ib->dgid));
0253 } else {
0254 slid = htonl(ntohs(ib->ib.slid));
0255 dlid = htonl(ntohs(ib->ib.dlid));
0256 }
0257 opa->opa.slid = slid;
0258 opa->opa.dlid = dlid;
0259 opa->service_id = ib->service_id;
0260 opa->opa.raw_traffic = ib->ib.raw_traffic;
0261 }
0262
0263
0264 static inline void sa_convert_path_opa_to_ib(struct sa_path_rec *dest,
0265 struct sa_path_rec *src)
0266 {
0267 if (src->rec_type != SA_PATH_REC_TYPE_OPA)
0268 return;
0269
0270 *dest = *src;
0271 dest->rec_type = SA_PATH_REC_TYPE_IB;
0272 path_conv_opa_to_ib(dest, src);
0273 }
0274
0275
0276 static inline void sa_convert_path_ib_to_opa(struct sa_path_rec *dest,
0277 struct sa_path_rec *src)
0278 {
0279 if (src->rec_type != SA_PATH_REC_TYPE_IB)
0280 return;
0281
0282
0283 *dest = *src;
0284 dest->rec_type = SA_PATH_REC_TYPE_OPA;
0285 path_conv_ib_to_opa(dest, src);
0286 }
0287
0288 #define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
0289 #define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
0290 #define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)
0291 #define IB_SA_MCMEMBER_REC_MLID IB_SA_COMP_MASK( 3)
0292 #define IB_SA_MCMEMBER_REC_MTU_SELECTOR IB_SA_COMP_MASK( 4)
0293 #define IB_SA_MCMEMBER_REC_MTU IB_SA_COMP_MASK( 5)
0294 #define IB_SA_MCMEMBER_REC_TRAFFIC_CLASS IB_SA_COMP_MASK( 6)
0295 #define IB_SA_MCMEMBER_REC_PKEY IB_SA_COMP_MASK( 7)
0296 #define IB_SA_MCMEMBER_REC_RATE_SELECTOR IB_SA_COMP_MASK( 8)
0297 #define IB_SA_MCMEMBER_REC_RATE IB_SA_COMP_MASK( 9)
0298 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(10)
0299 #define IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(11)
0300 #define IB_SA_MCMEMBER_REC_SL IB_SA_COMP_MASK(12)
0301 #define IB_SA_MCMEMBER_REC_FLOW_LABEL IB_SA_COMP_MASK(13)
0302 #define IB_SA_MCMEMBER_REC_HOP_LIMIT IB_SA_COMP_MASK(14)
0303 #define IB_SA_MCMEMBER_REC_SCOPE IB_SA_COMP_MASK(15)
0304 #define IB_SA_MCMEMBER_REC_JOIN_STATE IB_SA_COMP_MASK(16)
0305 #define IB_SA_MCMEMBER_REC_PROXY_JOIN IB_SA_COMP_MASK(17)
0306
0307 struct ib_sa_mcmember_rec {
0308 union ib_gid mgid;
0309 union ib_gid port_gid;
0310 __be32 qkey;
0311 __be16 mlid;
0312 u8 mtu_selector;
0313 u8 mtu;
0314 u8 traffic_class;
0315 __be16 pkey;
0316 u8 rate_selector;
0317 u8 rate;
0318 u8 packet_life_time_selector;
0319 u8 packet_life_time;
0320 u8 sl;
0321 __be32 flow_label;
0322 u8 hop_limit;
0323 u8 scope;
0324 u8 join_state;
0325 u8 proxy_join;
0326 };
0327
0328
0329 #define IB_SA_SERVICE_REC_SERVICE_ID IB_SA_COMP_MASK( 0)
0330 #define IB_SA_SERVICE_REC_SERVICE_GID IB_SA_COMP_MASK( 1)
0331 #define IB_SA_SERVICE_REC_SERVICE_PKEY IB_SA_COMP_MASK( 2)
0332
0333 #define IB_SA_SERVICE_REC_SERVICE_LEASE IB_SA_COMP_MASK( 4)
0334 #define IB_SA_SERVICE_REC_SERVICE_KEY IB_SA_COMP_MASK( 5)
0335 #define IB_SA_SERVICE_REC_SERVICE_NAME IB_SA_COMP_MASK( 6)
0336 #define IB_SA_SERVICE_REC_SERVICE_DATA8_0 IB_SA_COMP_MASK( 7)
0337 #define IB_SA_SERVICE_REC_SERVICE_DATA8_1 IB_SA_COMP_MASK( 8)
0338 #define IB_SA_SERVICE_REC_SERVICE_DATA8_2 IB_SA_COMP_MASK( 9)
0339 #define IB_SA_SERVICE_REC_SERVICE_DATA8_3 IB_SA_COMP_MASK(10)
0340 #define IB_SA_SERVICE_REC_SERVICE_DATA8_4 IB_SA_COMP_MASK(11)
0341 #define IB_SA_SERVICE_REC_SERVICE_DATA8_5 IB_SA_COMP_MASK(12)
0342 #define IB_SA_SERVICE_REC_SERVICE_DATA8_6 IB_SA_COMP_MASK(13)
0343 #define IB_SA_SERVICE_REC_SERVICE_DATA8_7 IB_SA_COMP_MASK(14)
0344 #define IB_SA_SERVICE_REC_SERVICE_DATA8_8 IB_SA_COMP_MASK(15)
0345 #define IB_SA_SERVICE_REC_SERVICE_DATA8_9 IB_SA_COMP_MASK(16)
0346 #define IB_SA_SERVICE_REC_SERVICE_DATA8_10 IB_SA_COMP_MASK(17)
0347 #define IB_SA_SERVICE_REC_SERVICE_DATA8_11 IB_SA_COMP_MASK(18)
0348 #define IB_SA_SERVICE_REC_SERVICE_DATA8_12 IB_SA_COMP_MASK(19)
0349 #define IB_SA_SERVICE_REC_SERVICE_DATA8_13 IB_SA_COMP_MASK(20)
0350 #define IB_SA_SERVICE_REC_SERVICE_DATA8_14 IB_SA_COMP_MASK(21)
0351 #define IB_SA_SERVICE_REC_SERVICE_DATA8_15 IB_SA_COMP_MASK(22)
0352 #define IB_SA_SERVICE_REC_SERVICE_DATA16_0 IB_SA_COMP_MASK(23)
0353 #define IB_SA_SERVICE_REC_SERVICE_DATA16_1 IB_SA_COMP_MASK(24)
0354 #define IB_SA_SERVICE_REC_SERVICE_DATA16_2 IB_SA_COMP_MASK(25)
0355 #define IB_SA_SERVICE_REC_SERVICE_DATA16_3 IB_SA_COMP_MASK(26)
0356 #define IB_SA_SERVICE_REC_SERVICE_DATA16_4 IB_SA_COMP_MASK(27)
0357 #define IB_SA_SERVICE_REC_SERVICE_DATA16_5 IB_SA_COMP_MASK(28)
0358 #define IB_SA_SERVICE_REC_SERVICE_DATA16_6 IB_SA_COMP_MASK(29)
0359 #define IB_SA_SERVICE_REC_SERVICE_DATA16_7 IB_SA_COMP_MASK(30)
0360 #define IB_SA_SERVICE_REC_SERVICE_DATA32_0 IB_SA_COMP_MASK(31)
0361 #define IB_SA_SERVICE_REC_SERVICE_DATA32_1 IB_SA_COMP_MASK(32)
0362 #define IB_SA_SERVICE_REC_SERVICE_DATA32_2 IB_SA_COMP_MASK(33)
0363 #define IB_SA_SERVICE_REC_SERVICE_DATA32_3 IB_SA_COMP_MASK(34)
0364 #define IB_SA_SERVICE_REC_SERVICE_DATA64_0 IB_SA_COMP_MASK(35)
0365 #define IB_SA_SERVICE_REC_SERVICE_DATA64_1 IB_SA_COMP_MASK(36)
0366
0367 #define IB_DEFAULT_SERVICE_LEASE 0xFFFFFFFF
0368
0369 #define IB_SA_GUIDINFO_REC_LID IB_SA_COMP_MASK(0)
0370 #define IB_SA_GUIDINFO_REC_BLOCK_NUM IB_SA_COMP_MASK(1)
0371 #define IB_SA_GUIDINFO_REC_RES1 IB_SA_COMP_MASK(2)
0372 #define IB_SA_GUIDINFO_REC_RES2 IB_SA_COMP_MASK(3)
0373 #define IB_SA_GUIDINFO_REC_GID0 IB_SA_COMP_MASK(4)
0374 #define IB_SA_GUIDINFO_REC_GID1 IB_SA_COMP_MASK(5)
0375 #define IB_SA_GUIDINFO_REC_GID2 IB_SA_COMP_MASK(6)
0376 #define IB_SA_GUIDINFO_REC_GID3 IB_SA_COMP_MASK(7)
0377 #define IB_SA_GUIDINFO_REC_GID4 IB_SA_COMP_MASK(8)
0378 #define IB_SA_GUIDINFO_REC_GID5 IB_SA_COMP_MASK(9)
0379 #define IB_SA_GUIDINFO_REC_GID6 IB_SA_COMP_MASK(10)
0380 #define IB_SA_GUIDINFO_REC_GID7 IB_SA_COMP_MASK(11)
0381
0382 struct ib_sa_guidinfo_rec {
0383 __be16 lid;
0384 u8 block_num;
0385
0386 u8 res1;
0387 __be32 res2;
0388 u8 guid_info_list[64];
0389 };
0390
0391 struct ib_sa_client {
0392 atomic_t users;
0393 struct completion comp;
0394 };
0395
0396
0397
0398
0399 void ib_sa_register_client(struct ib_sa_client *client);
0400
0401
0402
0403
0404
0405 void ib_sa_unregister_client(struct ib_sa_client *client);
0406
0407 struct ib_sa_query;
0408
0409 void ib_sa_cancel_query(int id, struct ib_sa_query *query);
0410
0411 int ib_sa_path_rec_get(struct ib_sa_client *client, struct ib_device *device,
0412 u32 port_num, struct sa_path_rec *rec,
0413 ib_sa_comp_mask comp_mask, unsigned long timeout_ms,
0414 gfp_t gfp_mask,
0415 void (*callback)(int status, struct sa_path_rec *resp,
0416 void *context),
0417 void *context, struct ib_sa_query **query);
0418
0419 struct ib_sa_multicast {
0420 struct ib_sa_mcmember_rec rec;
0421 ib_sa_comp_mask comp_mask;
0422 int (*callback)(int status,
0423 struct ib_sa_multicast *multicast);
0424 void *context;
0425 };
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455 struct ib_sa_multicast *ib_sa_join_multicast(struct ib_sa_client *client,
0456 struct ib_device *device,
0457 u32 port_num,
0458 struct ib_sa_mcmember_rec *rec,
0459 ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
0460 int (*callback)(int status,
0461 struct ib_sa_multicast
0462 *multicast),
0463 void *context);
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475 void ib_sa_free_multicast(struct ib_sa_multicast *multicast);
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486 int ib_sa_get_mcmember_rec(struct ib_device *device, u32 port_num,
0487 union ib_gid *mgid, struct ib_sa_mcmember_rec *rec);
0488
0489
0490
0491
0492
0493 int ib_init_ah_from_mcmember(struct ib_device *device, u32 port_num,
0494 struct ib_sa_mcmember_rec *rec,
0495 struct net_device *ndev,
0496 enum ib_gid_type gid_type,
0497 struct rdma_ah_attr *ah_attr);
0498
0499 int ib_init_ah_attr_from_path(struct ib_device *device, u32 port_num,
0500 struct sa_path_rec *rec,
0501 struct rdma_ah_attr *ah_attr,
0502 const struct ib_gid_attr *sgid_attr);
0503
0504
0505
0506
0507
0508 void ib_sa_pack_path(struct sa_path_rec *rec, void *attribute);
0509
0510
0511
0512
0513
0514 void ib_sa_unpack_path(void *attribute, struct sa_path_rec *rec);
0515
0516
0517 int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
0518 struct ib_device *device, u32 port_num,
0519 struct ib_sa_guidinfo_rec *rec,
0520 ib_sa_comp_mask comp_mask, u8 method,
0521 unsigned long timeout_ms, gfp_t gfp_mask,
0522 void (*callback)(int status,
0523 struct ib_sa_guidinfo_rec *resp,
0524 void *context),
0525 void *context, struct ib_sa_query **sa_query);
0526
0527 static inline bool sa_path_is_roce(struct sa_path_rec *rec)
0528 {
0529 return ((rec->rec_type == SA_PATH_REC_TYPE_ROCE_V1) ||
0530 (rec->rec_type == SA_PATH_REC_TYPE_ROCE_V2));
0531 }
0532
0533 static inline bool sa_path_is_opa(struct sa_path_rec *rec)
0534 {
0535 return (rec->rec_type == SA_PATH_REC_TYPE_OPA);
0536 }
0537
0538 static inline void sa_path_set_slid(struct sa_path_rec *rec, u32 slid)
0539 {
0540 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0541 rec->ib.slid = cpu_to_be16(slid);
0542 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0543 rec->opa.slid = cpu_to_be32(slid);
0544 }
0545
0546 static inline void sa_path_set_dlid(struct sa_path_rec *rec, u32 dlid)
0547 {
0548 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0549 rec->ib.dlid = cpu_to_be16(dlid);
0550 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0551 rec->opa.dlid = cpu_to_be32(dlid);
0552 }
0553
0554 static inline void sa_path_set_raw_traffic(struct sa_path_rec *rec,
0555 u8 raw_traffic)
0556 {
0557 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0558 rec->ib.raw_traffic = raw_traffic;
0559 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0560 rec->opa.raw_traffic = raw_traffic;
0561 }
0562
0563 static inline __be32 sa_path_get_slid(struct sa_path_rec *rec)
0564 {
0565 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0566 return htonl(ntohs(rec->ib.slid));
0567 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0568 return rec->opa.slid;
0569 return 0;
0570 }
0571
0572 static inline __be32 sa_path_get_dlid(struct sa_path_rec *rec)
0573 {
0574 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0575 return htonl(ntohs(rec->ib.dlid));
0576 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0577 return rec->opa.dlid;
0578 return 0;
0579 }
0580
0581 static inline u8 sa_path_get_raw_traffic(struct sa_path_rec *rec)
0582 {
0583 if (rec->rec_type == SA_PATH_REC_TYPE_IB)
0584 return rec->ib.raw_traffic;
0585 else if (rec->rec_type == SA_PATH_REC_TYPE_OPA)
0586 return rec->opa.raw_traffic;
0587 return 0;
0588 }
0589
0590 static inline void sa_path_set_dmac(struct sa_path_rec *rec, u8 *dmac)
0591 {
0592 if (sa_path_is_roce(rec))
0593 memcpy(rec->roce.dmac, dmac, ETH_ALEN);
0594 }
0595
0596 static inline void sa_path_set_dmac_zero(struct sa_path_rec *rec)
0597 {
0598 if (sa_path_is_roce(rec))
0599 eth_zero_addr(rec->roce.dmac);
0600 }
0601
0602 static inline u8 *sa_path_get_dmac(struct sa_path_rec *rec)
0603 {
0604 if (sa_path_is_roce(rec))
0605 return rec->roce.dmac;
0606 return NULL;
0607 }
0608 #endif