diff options
| author | Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> | 2017-04-27 19:06:00 -0400 |
|---|---|---|
| committer | Doug Ledford <dledford@redhat.com> | 2017-05-01 14:38:19 -0400 |
| commit | 9fdca4da4d8c83caefb9f2fd897d6a7bc355dfe6 (patch) | |
| tree | 002153e16e28b8817c25082e00ab2cc397fe9c34 /include/rdma | |
| parent | dfa834e1d97e24c7d6b7c5b102728d69d6361501 (diff) | |
IB/SA: Split struct sa_path_rec based on IB and ROCE specific fields
sa_path_rec now contains a union of sa_path_rec_ib and sa_path_rec_roce
based on the type of the path record. Note that fields applicable to
path record type ROCE v1 and ROCE v2 fall under sa_path_rec_roce.
Accessor functions are added to these fields so the caller doesn't have
to know the type.
Reviewed-by: Don Hiatt <don.hiatt@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/rdma')
| -rw-r--r-- | include/rdma/ib_sa.h | 147 |
1 files changed, 134 insertions, 13 deletions
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h index c00914783e12..c72c94949617 100644 --- a/include/rdma/ib_sa.h +++ b/include/rdma/ib_sa.h | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | 43 | ||
| 44 | #include <rdma/ib_verbs.h> | 44 | #include <rdma/ib_verbs.h> |
| 45 | #include <rdma/ib_mad.h> | 45 | #include <rdma/ib_mad.h> |
| 46 | #include <rdma/ib_addr.h> | ||
| 46 | 47 | ||
| 47 | enum { | 48 | enum { |
| 48 | IB_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */ | 49 | IB_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */ |
| @@ -147,19 +148,32 @@ enum ib_sa_mc_join_states { | |||
| 147 | #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20) | 148 | #define IB_SA_PATH_REC_PACKET_LIFE_TIME_SELECTOR IB_SA_COMP_MASK(20) |
| 148 | #define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21) | 149 | #define IB_SA_PATH_REC_PACKET_LIFE_TIME IB_SA_COMP_MASK(21) |
| 149 | #define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22) | 150 | #define IB_SA_PATH_REC_PREFERENCE IB_SA_COMP_MASK(22) |
| 151 | |||
| 150 | enum sa_path_rec_type { | 152 | enum sa_path_rec_type { |
| 151 | SA_PATH_REC_TYPE_IB, | 153 | SA_PATH_REC_TYPE_IB, |
| 152 | SA_PATH_REC_TYPE_ROCE_V1, | 154 | SA_PATH_REC_TYPE_ROCE_V1, |
| 153 | SA_PATH_REC_TYPE_ROCE_V2 | 155 | SA_PATH_REC_TYPE_ROCE_V2 |
| 154 | }; | 156 | }; |
| 155 | 157 | ||
| 156 | struct sa_path_rec { | 158 | struct sa_path_rec_ib { |
| 157 | __be64 service_id; | 159 | __be64 service_id; |
| 158 | union ib_gid dgid; | ||
| 159 | union ib_gid sgid; | ||
| 160 | __be16 dlid; | 160 | __be16 dlid; |
| 161 | __be16 slid; | 161 | __be16 slid; |
| 162 | u8 raw_traffic; | 162 | u8 raw_traffic; |
| 163 | }; | ||
| 164 | |||
| 165 | struct sa_path_rec_roce { | ||
| 166 | u8 dmac[ETH_ALEN]; | ||
| 167 | /* ignored in IB */ | ||
| 168 | int ifindex; | ||
| 169 | /* ignored in IB */ | ||
| 170 | struct net *net; | ||
| 171 | |||
| 172 | }; | ||
| 173 | |||
| 174 | struct sa_path_rec { | ||
| 175 | union ib_gid dgid; | ||
| 176 | union ib_gid sgid; | ||
| 163 | /* reserved */ | 177 | /* reserved */ |
| 164 | __be32 flow_label; | 178 | __be32 flow_label; |
| 165 | u8 hop_limit; | 179 | u8 hop_limit; |
| @@ -176,19 +190,13 @@ struct sa_path_rec { | |||
| 176 | u8 packet_life_time_selector; | 190 | u8 packet_life_time_selector; |
| 177 | u8 packet_life_time; | 191 | u8 packet_life_time; |
| 178 | u8 preference; | 192 | u8 preference; |
| 179 | u8 dmac[ETH_ALEN]; | 193 | union { |
| 180 | /* ignored in IB */ | 194 | struct sa_path_rec_ib ib; |
| 181 | int ifindex; | 195 | struct sa_path_rec_roce roce; |
| 182 | /* ignored in IB */ | 196 | }; |
| 183 | struct net *net; | ||
| 184 | enum sa_path_rec_type rec_type; | 197 | enum sa_path_rec_type rec_type; |
| 185 | }; | 198 | }; |
| 186 | 199 | ||
| 187 | static inline struct net_device *ib_get_ndev_from_path(struct sa_path_rec *rec) | ||
| 188 | { | ||
| 189 | return rec->net ? dev_get_by_index(rec->net, rec->ifindex) : NULL; | ||
| 190 | } | ||
| 191 | |||
| 192 | static inline enum ib_gid_type | 200 | static inline enum ib_gid_type |
| 193 | sa_conv_pathrec_to_gid_type(struct sa_path_rec *rec) | 201 | sa_conv_pathrec_to_gid_type(struct sa_path_rec *rec) |
| 194 | { | 202 | { |
| @@ -490,4 +498,117 @@ bool ib_sa_sendonly_fullmem_support(struct ib_sa_client *client, | |||
| 490 | struct ib_device *device, | 498 | struct ib_device *device, |
| 491 | u8 port_num); | 499 | u8 port_num); |
| 492 | 500 | ||
| 501 | static inline bool sa_path_is_roce(struct sa_path_rec *rec) | ||
| 502 | { | ||
| 503 | return ((rec->rec_type == SA_PATH_REC_TYPE_ROCE_V1) || | ||
| 504 | (rec->rec_type == SA_PATH_REC_TYPE_ROCE_V2)); | ||
| 505 | } | ||
| 506 | |||
| 507 | static inline void sa_path_set_service_id(struct sa_path_rec *rec, | ||
| 508 | __be64 service_id) | ||
| 509 | { | ||
| 510 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 511 | rec->ib.service_id = service_id; | ||
| 512 | } | ||
| 513 | |||
| 514 | static inline void sa_path_set_slid(struct sa_path_rec *rec, __be16 slid) | ||
| 515 | { | ||
| 516 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 517 | rec->ib.slid = slid; | ||
| 518 | } | ||
| 519 | |||
| 520 | static inline void sa_path_set_dlid(struct sa_path_rec *rec, __be16 dlid) | ||
| 521 | { | ||
| 522 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 523 | rec->ib.dlid = dlid; | ||
| 524 | } | ||
| 525 | |||
| 526 | static inline void sa_path_set_raw_traffic(struct sa_path_rec *rec, | ||
| 527 | u8 raw_traffic) | ||
| 528 | { | ||
| 529 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 530 | rec->ib.raw_traffic = raw_traffic; | ||
| 531 | } | ||
| 532 | |||
| 533 | static inline __be64 sa_path_get_service_id(struct sa_path_rec *rec) | ||
| 534 | { | ||
| 535 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 536 | return rec->ib.service_id; | ||
| 537 | return 0; | ||
| 538 | } | ||
| 539 | |||
| 540 | static inline __be16 sa_path_get_slid(struct sa_path_rec *rec) | ||
| 541 | { | ||
| 542 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 543 | return rec->ib.slid; | ||
| 544 | return 0; | ||
| 545 | } | ||
| 546 | |||
| 547 | static inline __be16 sa_path_get_dlid(struct sa_path_rec *rec) | ||
| 548 | { | ||
| 549 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 550 | return rec->ib.dlid; | ||
| 551 | return 0; | ||
| 552 | } | ||
| 553 | |||
| 554 | static inline u8 sa_path_get_raw_traffic(struct sa_path_rec *rec) | ||
| 555 | { | ||
| 556 | if (rec->rec_type == SA_PATH_REC_TYPE_IB) | ||
| 557 | return rec->ib.raw_traffic; | ||
| 558 | return 0; | ||
| 559 | } | ||
| 560 | |||
| 561 | static inline void sa_path_set_dmac(struct sa_path_rec *rec, u8 *dmac) | ||
| 562 | { | ||
| 563 | if (sa_path_is_roce(rec)) | ||
| 564 | memcpy(rec->roce.dmac, dmac, ETH_ALEN); | ||
| 565 | } | ||
| 566 | |||
| 567 | static inline void sa_path_set_dmac_zero(struct sa_path_rec *rec) | ||
| 568 | { | ||
| 569 | if (sa_path_is_roce(rec)) | ||
| 570 | eth_zero_addr(rec->roce.dmac); | ||
| 571 | } | ||
| 572 | |||
| 573 | static inline void sa_path_set_ifindex(struct sa_path_rec *rec, int ifindex) | ||
| 574 | { | ||
| 575 | if (sa_path_is_roce(rec)) | ||
| 576 | rec->roce.ifindex = ifindex; | ||
| 577 | } | ||
| 578 | |||
| 579 | static inline void sa_path_set_ndev(struct sa_path_rec *rec, struct net *net) | ||
| 580 | { | ||
| 581 | if (sa_path_is_roce(rec)) | ||
| 582 | rec->roce.net = net; | ||
| 583 | } | ||
| 584 | |||
| 585 | static inline u8 *sa_path_get_dmac(struct sa_path_rec *rec) | ||
| 586 | { | ||
| 587 | if (sa_path_is_roce(rec)) | ||
| 588 | return rec->roce.dmac; | ||
| 589 | return NULL; | ||
| 590 | } | ||
| 591 | |||
| 592 | static inline int sa_path_get_ifindex(struct sa_path_rec *rec) | ||
| 593 | { | ||
| 594 | if (sa_path_is_roce(rec)) | ||
| 595 | return rec->roce.ifindex; | ||
| 596 | return 0; | ||
| 597 | } | ||
| 598 | |||
| 599 | static inline struct net *sa_path_get_ndev(struct sa_path_rec *rec) | ||
| 600 | { | ||
| 601 | if (sa_path_is_roce(rec)) | ||
| 602 | return rec->roce.net; | ||
| 603 | return NULL; | ||
| 604 | } | ||
| 605 | |||
| 606 | static inline struct net_device *ib_get_ndev_from_path(struct sa_path_rec *rec) | ||
| 607 | { | ||
| 608 | return sa_path_get_ndev(rec) ? | ||
| 609 | dev_get_by_index(sa_path_get_ndev(rec), | ||
| 610 | sa_path_get_ifindex(rec)) | ||
| 611 | : NULL; | ||
| 612 | } | ||
| 613 | |||
| 493 | #endif /* IB_SA_H */ | 614 | #endif /* IB_SA_H */ |
