Skip to content

Commit 2224c47

Browse files
Dasaratharaman Chandramoulidledford
authored andcommitted
IB/core: Add accessor functions for rdma_ah_attr fields
These accessor functions are supposed to be used to get and set individual fields of struct rdma_ah_attr Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Don Hiatt <[email protected]> Reviewed-by: Sean Hefty <[email protected]> Signed-off-by: Dasaratharaman Chandramouli <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent f988653 commit 2224c47

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

include/rdma/ib_verbs.h

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,4 +3465,125 @@ void ib_drain_qp(struct ib_qp *qp);
34653465

34663466
int ib_resolve_eth_dmac(struct ib_device *device,
34673467
struct rdma_ah_attr *ah_attr);
3468+
3469+
static inline u8 *rdma_ah_retrieve_dmac(struct rdma_ah_attr *attr)
3470+
{
3471+
return attr->dmac;
3472+
}
3473+
3474+
static inline void rdma_ah_set_dlid(struct rdma_ah_attr *attr, u32 dlid)
3475+
{
3476+
attr->dlid = (u16)dlid;
3477+
}
3478+
3479+
static inline u32 rdma_ah_get_dlid(const struct rdma_ah_attr *attr)
3480+
{
3481+
return attr->dlid;
3482+
}
3483+
3484+
static inline void rdma_ah_set_sl(struct rdma_ah_attr *attr, u8 sl)
3485+
{
3486+
attr->sl = sl;
3487+
}
3488+
3489+
static inline u8 rdma_ah_get_sl(const struct rdma_ah_attr *attr)
3490+
{
3491+
return attr->sl;
3492+
}
3493+
3494+
static inline void rdma_ah_set_path_bits(struct rdma_ah_attr *attr,
3495+
u8 src_path_bits)
3496+
{
3497+
attr->src_path_bits = src_path_bits;
3498+
}
3499+
3500+
static inline u8 rdma_ah_get_path_bits(const struct rdma_ah_attr *attr)
3501+
{
3502+
return attr->src_path_bits;
3503+
}
3504+
3505+
static inline void rdma_ah_set_port_num(struct rdma_ah_attr *attr, u8 port_num)
3506+
{
3507+
attr->port_num = port_num;
3508+
}
3509+
3510+
static inline u8 rdma_ah_get_port_num(const struct rdma_ah_attr *attr)
3511+
{
3512+
return attr->port_num;
3513+
}
3514+
3515+
static inline void rdma_ah_set_static_rate(struct rdma_ah_attr *attr,
3516+
u8 static_rate)
3517+
{
3518+
attr->static_rate = static_rate;
3519+
}
3520+
3521+
static inline u8 rdma_ah_get_static_rate(const struct rdma_ah_attr *attr)
3522+
{
3523+
return attr->static_rate;
3524+
}
3525+
3526+
static inline void rdma_ah_set_ah_flags(struct rdma_ah_attr *attr,
3527+
enum ib_ah_flags flag)
3528+
{
3529+
attr->ah_flags = flag;
3530+
}
3531+
3532+
static inline enum ib_ah_flags
3533+
rdma_ah_get_ah_flags(const struct rdma_ah_attr *attr)
3534+
{
3535+
return attr->ah_flags;
3536+
}
3537+
3538+
static inline const struct ib_global_route
3539+
*rdma_ah_read_grh(const struct rdma_ah_attr *attr)
3540+
{
3541+
return &attr->grh;
3542+
}
3543+
3544+
/*To retrieve and modify the grh */
3545+
static inline struct ib_global_route
3546+
*rdma_ah_retrieve_grh(struct rdma_ah_attr *attr)
3547+
{
3548+
return &attr->grh;
3549+
}
3550+
3551+
static inline void rdma_ah_set_dgid_raw(struct rdma_ah_attr *attr, void *dgid)
3552+
{
3553+
struct ib_global_route *grh = rdma_ah_retrieve_grh(attr);
3554+
3555+
memcpy(grh->dgid.raw, dgid, sizeof(grh->dgid));
3556+
}
3557+
3558+
static inline void rdma_ah_set_subnet_prefix(struct rdma_ah_attr *attr,
3559+
__be64 prefix)
3560+
{
3561+
struct ib_global_route *grh = rdma_ah_retrieve_grh(attr);
3562+
3563+
grh->dgid.global.subnet_prefix = prefix;
3564+
}
3565+
3566+
static inline void rdma_ah_set_interface_id(struct rdma_ah_attr *attr,
3567+
__be64 if_id)
3568+
{
3569+
struct ib_global_route *grh = rdma_ah_retrieve_grh(attr);
3570+
3571+
grh->dgid.global.interface_id = if_id;
3572+
}
3573+
3574+
static inline void rdma_ah_set_grh(struct rdma_ah_attr *attr,
3575+
union ib_gid *dgid, u32 flow_label,
3576+
u8 sgid_index, u8 hop_limit,
3577+
u8 traffic_class)
3578+
{
3579+
struct ib_global_route *grh = rdma_ah_retrieve_grh(attr);
3580+
3581+
attr->ah_flags = IB_AH_GRH;
3582+
if (dgid)
3583+
grh->dgid = *dgid;
3584+
grh->flow_label = flow_label;
3585+
grh->sgid_index = sgid_index;
3586+
grh->hop_limit = hop_limit;
3587+
grh->traffic_class = traffic_class;
3588+
}
34683589
#endif /* IB_VERBS_H */

0 commit comments

Comments
 (0)