Skip to content

Commit

Permalink
irdma(4): Upgrade the driver to 1.1.11-k
Browse files Browse the repository at this point in the history
Summary of changes:
- postpone mtu size assignment during load to avoid race condition
- refactor some of the debug prints
- add request reset handler
- refactor flush scheduler to increase efficiency and avoid racing
- put correct vlan_tag for UD traffic with PFC
- suspend QP before going to ERROR state to avoid CQP timout
- fix arithmetic error on irdma_debug_bugf
- allow debug flag to be settable during driver load
- introduce meaningful default values for DCQCN algorithm
- interrupt naming convention improvements
- skip unsignaled completions in poll_cmpl

Signed-off-by: Bartosz Sobczak [email protected]
Signed-off-by: Eric Joyner <[email protected]>

Reviewed by:	hselasky@
MFC after:	1 week
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D39173
  • Loading branch information
bsobczak authored and ricera committed Mar 28, 2023
1 parent b674303 commit 3510590
Show file tree
Hide file tree
Showing 37 changed files with 994 additions and 641 deletions.
2 changes: 2 additions & 0 deletions contrib/ofed/libirdma/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct irdma_get_context {
__u32 rsvd32;
__u8 userspace_ver;
__u8 rsvd8[3];
__aligned_u64 comp_mask;

};
struct irdma_get_context_resp {
Expand All @@ -136,6 +137,7 @@ struct irdma_get_context_resp {
__u16 max_hw_sq_chunk;
__u8 hw_rev;
__u8 rsvd2;
__aligned_u64 comp_mask;

};
struct irdma_ureg_mr {
Expand Down
4 changes: 2 additions & 2 deletions contrib/ofed/libirdma/i40iw_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ enum i40iw_device_caps_const {
I40IW_MAX_SGE_RD = 1,
I40IW_MAX_PUSH_PAGE_COUNT = 0,
I40IW_MAX_INLINE_DATA_SIZE = 48,
I40IW_MAX_IRD_SIZE = 63,
I40IW_MAX_ORD_SIZE = 127,
I40IW_MAX_IRD_SIZE = 64,
I40IW_MAX_ORD_SIZE = 64,
I40IW_MAX_WQ_ENTRIES = 2048,
I40IW_MAX_WQE_SIZE_RQ = 128,
I40IW_MAX_PDS = 32768,
Expand Down
8 changes: 7 additions & 1 deletion contrib/ofed/libirdma/irdma-abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB)
*
*
* Copyright (c) 2006 - 2021 Intel Corporation. All rights reserved.
* Copyright (c) 2006 - 2022 Intel Corporation. All rights reserved.
* Copyright (c) 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
Expand Down Expand Up @@ -53,10 +53,15 @@ enum irdma_memreg_type {
IRDMA_MEMREG_TYPE_CQ = 2,
};

enum {
IRDMA_ALLOC_UCTX_USE_RAW_ATTR = 1 << 0,
};

struct irdma_alloc_ucontext_req {
__u32 rsvd32;
__u8 userspace_ver;
__u8 rsvd8[3];
__aligned_u64 comp_mask;
};

struct irdma_alloc_ucontext_resp {
Expand All @@ -77,6 +82,7 @@ struct irdma_alloc_ucontext_resp {
__u16 max_hw_sq_chunk;
__u8 hw_rev;
__u8 rsvd2;
__aligned_u64 comp_mask;
};

struct irdma_alloc_pd_resp {
Expand Down
18 changes: 12 additions & 6 deletions contrib/ofed/libirdma/irdma_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define IRDMA_CQE_QTYPE_RQ 0
#define IRDMA_CQE_QTYPE_SQ 1

#define IRDMA_QP_SW_MIN_WQSIZE 8 /* in WRs*/
#define IRDMA_QP_WQE_MIN_SIZE 32
#define IRDMA_QP_WQE_MAX_SIZE 256
#define IRDMA_QP_WQE_MIN_QUANTA 1
Expand Down Expand Up @@ -304,6 +305,17 @@
#define IRDMAPFINT_OICR_PE_PUSH_M BIT(27)
#define IRDMAPFINT_OICR_PE_CRITERR_M BIT(28)

#define IRDMA_GET_RING_OFFSET(_ring, _i) \
( \
((_ring).head + (_i)) % (_ring).size \
)

#define IRDMA_GET_CQ_ELEM_AT_OFFSET(_cq, _i, _cqe) \
{ \
register __u32 offset; \
offset = IRDMA_GET_RING_OFFSET((_cq)->cq_ring, _i); \
(_cqe) = (_cq)->cq_base[offset].buf; \
}
#define IRDMA_GET_CURRENT_CQ_ELEM(_cq) \
( \
(_cq)->cq_base[IRDMA_RING_CURRENT_HEAD((_cq)->cq_ring)].buf \
Expand Down Expand Up @@ -437,12 +449,6 @@
IRDMA_RING_MOVE_HEAD(_ring, _retcode); \
}

enum irdma_protocol_used {
IRDMA_ANY_PROTOCOL = 0,
IRDMA_IWARP_PROTOCOL_ONLY = 1,
IRDMA_ROCE_PROTOCOL_ONLY = 2,
};

enum irdma_qp_wqe_size {
IRDMA_WQE_SIZE_32 = 32,
IRDMA_WQE_SIZE_64 = 64,
Expand Down
13 changes: 6 additions & 7 deletions contrib/ofed/libirdma/irdma_uk.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ irdma_copy_inline_data_gen_1(u8 *wqe, struct irdma_sge *sge_list,
sge_len -= bytes_copied;

if (!quanta_bytes_remaining) {
/* Remaining inline bytes reside after the hdr */
/* Remaining inline bytes reside after hdr */
wqe += 16;
quanta_bytes_remaining = 32;
}
Expand Down Expand Up @@ -710,7 +710,7 @@ irdma_copy_inline_data(u8 *wqe, struct irdma_sge *sge_list, u32 num_sges,
if (!quanta_bytes_remaining) {
quanta_bytes_remaining = 31;

/* Remaining inline bytes reside after the hdr */
/* Remaining inline bytes reside after hdr */
if (first_quanta) {
first_quanta = false;
wqe += 16;
Expand Down Expand Up @@ -1111,7 +1111,6 @@ irdma_uk_cq_request_notification(struct irdma_cq_uk *cq,
u8 arm_next = 0;
u8 arm_seq_num;

cq->armed = true;
get_64bit_val(cq->shadow_area, IRDMA_BYTE_32, &temp_val);
arm_seq_num = (u8)FIELD_GET(IRDMA_CQ_DBSA_ARM_SEQ_NUM, temp_val);
arm_seq_num++;
Expand Down Expand Up @@ -1338,6 +1337,8 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
info->error = (bool)FIELD_GET(IRDMA_CQ_ERROR, qword3);
info->push_dropped = (bool)FIELD_GET(IRDMACQ_PSHDROP, qword3);
info->ipv4 = (bool)FIELD_GET(IRDMACQ_IPV4, qword3);
get_64bit_val(cqe, IRDMA_BYTE_8, &comp_ctx);
qp = (struct irdma_qp_uk *)(irdma_uintptr) comp_ctx;
if (info->error) {
info->major_err = FIELD_GET(IRDMA_CQ_MAJERR, qword3);
info->minor_err = FIELD_GET(IRDMA_CQ_MINERR, qword3);
Expand Down Expand Up @@ -1366,10 +1367,7 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
info->qp_id = (u32)FIELD_GET(IRDMACQ_QPID, qword2);
info->ud_src_qpn = (u32)FIELD_GET(IRDMACQ_UDSRCQPN, qword2);

get_64bit_val(cqe, IRDMA_BYTE_8, &comp_ctx);

info->solicited_event = (bool)FIELD_GET(IRDMACQ_SOEVENT, qword3);
qp = (struct irdma_qp_uk *)(irdma_uintptr) comp_ctx;
if (!qp || qp->destroy_pending) {
ret_code = EFAULT;
goto exit;
Expand Down Expand Up @@ -1493,7 +1491,8 @@ irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
}
} while (1);

if (info->op_type == IRDMA_OP_TYPE_BIND_MW && info->minor_err == FLUSH_PROT_ERR)
if (info->op_type == IRDMA_OP_TYPE_BIND_MW &&
info->minor_err == FLUSH_PROT_ERR)
info->minor_err = FLUSH_MW_BIND_ERR;
qp->sq_flush_seen = true;
if (!IRDMA_RING_MORE_WORK(qp->sq_ring))
Expand Down
4 changes: 2 additions & 2 deletions contrib/ofed/libirdma/irdma_umain.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/**
* Driver version
*/
char libirdma_version[] = "1.1.5-k";
char libirdma_version[] = "1.1.11-k";

unsigned int irdma_dbg;

Expand Down Expand Up @@ -170,7 +170,7 @@ irdma_init_context(struct verbs_device *vdev,
iwvctx->uk_attrs.max_hw_sq_chunk = resp.max_hw_sq_chunk;
iwvctx->uk_attrs.max_hw_cq_size = resp.max_hw_cq_size;
iwvctx->uk_attrs.min_hw_cq_size = resp.min_hw_cq_size;
iwvctx->uk_attrs.min_hw_wq_size = IRDMA_MIN_WQ_SIZE_GEN2;
iwvctx->uk_attrs.min_hw_wq_size = IRDMA_QP_SW_MIN_WQSIZE;
iwvctx->abi_ver = IRDMA_ABI_VER;
mmap_key = resp.db_mmap_key;

Expand Down
3 changes: 2 additions & 1 deletion contrib/ofed/libirdma/irdma_umain.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ struct irdma_uvcontext {
struct irdma_uk_attrs uk_attrs;
void *db;
int abi_ver;
bool legacy_mode;
bool legacy_mode:1;
bool use_raw_attrs:1;
};

struct irdma_uqp;
Expand Down
2 changes: 0 additions & 2 deletions contrib/ofed/libirdma/irdma_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ enum irdma_device_caps_const {
IRDMA_Q2_BUF_SIZE = 256,
IRDMA_QP_CTX_SIZE = 256,
IRDMA_MAX_PDS = 262144,
IRDMA_MIN_WQ_SIZE_GEN2 = 8,
};

enum irdma_addressing_type {
Expand Down Expand Up @@ -521,7 +520,6 @@ struct irdma_cq_uk {
u32 cq_size;
struct irdma_ring cq_ring;
u8 polarity;
bool armed:1;
bool avoid_mem_cflct:1;
};

Expand Down
7 changes: 3 additions & 4 deletions contrib/ofed/libirdma/irdma_uverbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1566,11 +1566,10 @@ irdma_ucreate_qp(struct ibv_pd *pd,
info.sq_size = info.sq_depth >> info.sq_shift;
info.rq_size = info.rq_depth >> info.rq_shift;
/**
* For older ABI version (less than 6) passes raw sq and rq
* quanta in cap.max_send_wr and cap.max_recv_wr.
* But then kernel had no way of calculating the actual qp size.
* Maintain backward compatibility with older ABI which pass sq
* and rq depth (in quanta) in cap.max_send_wr a cap.max_recv_wr
*/
if (iwvctx->abi_ver <= 5) {
if (!iwvctx->use_raw_attrs) {
attr->cap.max_send_wr = info.sq_size;
attr->cap.max_recv_wr = info.rq_size;
}
Expand Down
9 changes: 5 additions & 4 deletions contrib/ofed/libirdma/osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ do { \
irdma_debug(dev, mask, "%s\n", desc); \
irdma_debug(dev, mask, "starting address virt=%p phy=%lxh\n", buf, irdma_get_virt_to_phy(buf)); \
for (i = 0; i < size ; i += 8) \
irdma_debug(dev, mask, "index %03d val: %016lx\n", i, ((unsigned long *)buf)[i / 8]); \
irdma_debug(dev, mask, "index %03d val: %016lx\n", i, ((unsigned long *)(buf))[i / 8]); \
} while(0)

#define irdma_debug(h, m, s, ...) \
Expand All @@ -137,11 +137,12 @@ do { \
if (irdma_dbg) \
printf("libirdma-%s: " fmt, __func__, ##args); \
} while (0)
#define irdma_dev_err(a, b, ...) printf(b, ##__VA_ARGS__)
#define irdma_dev_warn(a, b, ...) printf(b, ##__VA_ARGS__) /*dev_warn(a, b)*/
#define irdma_dev_err(ibdev, fmt, ...) \
pr_err("%s:%s:%d ERR "fmt, (ibdev)->name, __func__, __LINE__, ##__VA_ARGS__)
#define irdma_dev_warn(ibdev, fmt, ...) \
pr_warn("%s:%s:%d WARN "fmt, (ibdev)->name, __func__, __LINE__, ##__VA_ARGS__)
#define irdma_dev_info(a, b, ...) printf(b, ##__VA_ARGS__)
#define irdma_pr_warn printf
#define ibdev_err(ibdev, fmt, ...) printf("%s:"fmt, (ibdev)->name, ##__VA_ARGS__)

#define dump_struct(s, sz, name) \
do { \
Expand Down
58 changes: 52 additions & 6 deletions sys/dev/irdma/fbsd_kcompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ irdma_wr64(struct irdma_dev_ctx *dev_ctx, u32 reg, u64 value)

}

void
irdma_request_reset(struct irdma_pci_f *rf)
{
struct ice_rdma_peer *peer = rf->peer_info;
struct ice_rdma_request req = {0};

req.type = ICE_RDMA_EVENT_RESET;

printf("%s:%d requesting pf-reset\n", __func__, __LINE__);
IRDMA_DI_REQ_HANDLER(peer, &req);
}

int
irdma_register_qset(struct irdma_sc_vsi *vsi, struct irdma_ws_node *tc_node)
{
Expand Down Expand Up @@ -611,32 +623,38 @@ irdma_dcqcn_tunables_init(struct irdma_pci_f *rf)
&rf->dcqcn_params.min_rate, 0,
"set minimum rate limit value, in MBits per second, default=0");

rf->dcqcn_params.dcqcn_f = 5;
SYSCTL_ADD_U8(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_F", CTLFLAG_RDTUN, &rf->dcqcn_params.dcqcn_f, 0,
"set number of times to stay in each stage of bandwidth recovery, default=0");
"set number of times to stay in each stage of bandwidth recovery, default=5");

rf->dcqcn_params.dcqcn_t = 0x37;
SYSCTL_ADD_U16(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_T", CTLFLAG_RDTUN, &rf->dcqcn_params.dcqcn_t, 0,
"set number of usecs that should elapse before increasing the CWND in DCQCN mode, default=0");
"set number of usecs that should elapse before increasing the CWND in DCQCN mode, default=0x37");

rf->dcqcn_params.dcqcn_b = 0x249f0;
SYSCTL_ADD_U32(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_B", CTLFLAG_RDTUN, &rf->dcqcn_params.dcqcn_b, 0,
"set number of MSS to add to the congestion window in additive increase mode, default=0");
"set number of MSS to add to the congestion window in additive increase mode, default=0x249f0");

rf->dcqcn_params.rai_factor = 1;
SYSCTL_ADD_U16(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_rai_factor", CTLFLAG_RDTUN,
&rf->dcqcn_params.rai_factor, 0,
"set number of MSS to add to the congestion window in additive increase mode, default=0");
"set number of MSS to add to the congestion window in additive increase mode, default=1");

rf->dcqcn_params.hai_factor = 5;
SYSCTL_ADD_U16(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_hai_factor", CTLFLAG_RDTUN,
&rf->dcqcn_params.hai_factor, 0,
"set number of MSS to add to the congestion window in hyperactive increase mode, default=0");
"set number of MSS to add to the congestion window in hyperactive increase mode, default=5");

rf->dcqcn_params.rreduce_mperiod = 50;
SYSCTL_ADD_U32(&rf->tun_info.irdma_sysctl_ctx, irdma_sysctl_oid_list,
OID_AUTO, "dcqcn_rreduce_mperiod", CTLFLAG_RDTUN,
&rf->dcqcn_params.rreduce_mperiod, 0,
"set minimum time between 2 consecutive rate reductions for a single flow, default=0");
"set minimum time between 2 consecutive rate reductions for a single flow, default=50");
}

/**
Expand Down Expand Up @@ -743,3 +761,31 @@ irdma_prm_rem_bitmapmem(struct irdma_hw *hw, struct irdma_chunk *chunk)
{
kfree(chunk->bitmapmem.va);
}

void
irdma_cleanup_dead_qps(struct irdma_sc_vsi *vsi)
{
struct irdma_sc_qp *qp = NULL;
struct irdma_qp *iwqp;
struct irdma_pci_f *rf;
u8 i;

for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++) {
qp = irdma_get_qp_from_list(&vsi->qos[i].qplist, qp);
while (qp) {
if (qp->qp_uk.qp_type == IRDMA_QP_TYPE_UDA) {
qp = irdma_get_qp_from_list(&vsi->qos[i].qplist, qp);
continue;
}
iwqp = qp->qp_uk.back_qp;
rf = iwqp->iwdev->rf;
irdma_free_dma_mem(rf->sc_dev.hw, &iwqp->q2_ctx_mem);
irdma_free_dma_mem(rf->sc_dev.hw, &iwqp->kqp.dma_mem);

kfree(iwqp->kqp.sq_wrid_mem);
kfree(iwqp->kqp.rq_wrid_mem);
qp = irdma_get_qp_from_list(&vsi->qos[i].qplist, qp);
kfree(iwqp);
}
}
}
16 changes: 13 additions & 3 deletions sys/dev/irdma/fbsd_kcompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
#define TASKLET_DATA_TYPE unsigned long
#define TASKLET_FUNC_TYPE void (*)(TASKLET_DATA_TYPE)

#ifndef tasklet_setup
#define tasklet_setup(tasklet, callback) \
tasklet_init((tasklet), (TASKLET_FUNC_TYPE)(callback), \
(TASKLET_DATA_TYPE)(tasklet))

#endif
#ifndef from_tasklet
#define from_tasklet(var, callback_tasklet, tasklet_fieldname) \
container_of(callback_tasklet, typeof(*var), tasklet_fieldname)
Expand Down Expand Up @@ -176,8 +177,7 @@ int irdma_dereg_mr(struct ib_mr *ib_mr);
#else
int irdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata);
#endif
void irdma_get_eth_speed_and_width(u32 link_speed, u8 *active_speed,
u8 *active_width);
int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u8 *speed, u8 *width);
enum rdma_link_layer irdma_get_link_layer(struct ib_device *ibdev,
u8 port_num);
int irdma_roce_port_immutable(struct ib_device *ibdev, u8 port_num,
Expand All @@ -197,6 +197,7 @@ int irdma_get_hw_stats(struct ib_device *ibdev,
struct rdma_hw_stats *stats, u8 port_num,
int index);

void irdma_request_reset(struct irdma_pci_f *rf);
int irdma_register_qset(struct irdma_sc_vsi *vsi,
struct irdma_ws_node *tc_node);
void irdma_unregister_qset(struct irdma_sc_vsi *vsi,
Expand Down Expand Up @@ -337,4 +338,13 @@ static inline size_t irdma_ib_umem_num_dma_blocks(struct ib_umem *umem, unsigned
ALIGN_DOWN(iova, pgsz))) / pgsz;
}

static inline void addrconf_addr_eui48(u8 *deui, const char *const addr)
{
memcpy(deui, addr, 3);
deui[3] = 0xFF;
deui[4] = 0xFE;
memcpy(deui + 5, addr + 3, 3);
deui[0] ^= 2;
}

#endif /* FBSD_KCOMPAT_H */
Loading

0 comments on commit 3510590

Please sign in to comment.