Add infrastructure to support sending crypto commands using the midpath channels (MPCs). bnxt_xmit_crypto_cmd() is used to send a crypto command and sleep with timeout until the completion is received. If it times out, we recover by resetting the MPC. The next patch will use this infrastructure to offload kTLS connections. Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + .../net/ethernet/broadcom/bnxt/bnxt_crypto.c | 145 ++++++++++++++- .../net/ethernet/broadcom/bnxt/bnxt_crypto.h | 92 ++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c | 171 +++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h | 9 + 6 files changed, 418 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index a772b86842c1..74935b119569 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7714,7 +7714,7 @@ void bnxt_hwrm_cp_ring_free(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) ring->fw_ring_id = INVALID_HW_RING_ID; } -static void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) +void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) { struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; int i, size = ring->ring_mem.page_size; @@ -14368,7 +14368,7 @@ static int bnxt_hwrm_rx_ring_reset(struct bnxt *bp, int ring_nr) return hwrm_req_send_silent(bp, req); } -static void bnxt_reset_task(struct bnxt *bp, bool silent) +void bnxt_reset_task(struct bnxt *bp, bool silent) { if (!silent) bnxt_dbg_dump_states(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index f30e7c90471b..fc9fec10e753 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -3019,6 +3019,7 @@ int bnxt_hwrm_tx_ring_alloc(struct bnxt *bp, struct bnxt_tx_ring_info *txr, void bnxt_hwrm_tx_ring_free(struct bnxt *bp, struct bnxt_tx_ring_info *txr, bool close_path); void bnxt_hwrm_cp_ring_free(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); +void bnxt_clear_one_cp_ring(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_total_tx_rings(struct bnxt *bp); int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); int bnxt_nq_rings_in_use(struct bnxt *bp); @@ -3064,6 +3065,7 @@ void bnxt_get_ring_drv_stats(struct bnxt *bp, bool bnxt_rfs_capable(struct bnxt *bp, bool new_rss_ctx); int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words, u32 *reg_buf); +void bnxt_reset_task(struct bnxt *bp, bool silent); void bnxt_fw_exception(struct bnxt *bp); void bnxt_fw_reset(struct bnxt *bp); int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.c index 4ea3e67be9f5..2cacce28676d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.c @@ -5,10 +5,12 @@ #include #include #include +#include #include #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_mpc.h" #include "bnxt_crypto.h" static u32 bnxt_get_max_crypto_key_ctx(struct bnxt *bp, int key_type) @@ -46,6 +48,7 @@ void bnxt_alloc_crypto_info(struct bnxt *bp, return; if (!crypto) { struct bnxt_kctx *kctx; + char name[64]; int i; crypto = kzalloc_obj(*crypto); @@ -54,6 +57,15 @@ void bnxt_alloc_crypto_info(struct bnxt *bp, "Unable to allocate crypto info\n"); return; } + snprintf(name, sizeof(name), "bnxt_crypto-%s", + dev_name(&bp->pdev->dev)); + crypto->mpc_cache = + kmem_cache_create(name, + sizeof(struct bnxt_crypto_cmd_ctx), + 0, SLAB_HWCACHE_ALIGN, NULL); + if (!crypto->mpc_cache) + goto alloc_err; + for (i = 0; i < BNXT_MAX_CRYPTO_KEY_TYPE; i++) { kctx = &crypto->kctx[i]; kctx->type = i; @@ -66,6 +78,11 @@ void bnxt_alloc_crypto_info(struct bnxt *bp, bp->crypto_info = crypto; } crypto->max_key_ctxs_alloc = max_keys; + return; + +alloc_err: + kfree(crypto); + bp->crypto_info = NULL; } /** @@ -113,8 +130,13 @@ void bnxt_clear_crypto(struct bnxt *bp) */ void bnxt_free_crypto_info(struct bnxt *bp) { + struct bnxt_crypto_info *crypto = bp->crypto_info; + + if (!crypto) + return; bnxt_clear_crypto(bp); - kfree(bp->crypto_info); + kmem_cache_destroy(crypto->mpc_cache); + kfree(crypto); bp->crypto_info = NULL; } @@ -333,6 +355,90 @@ int bnxt_key_ctx_alloc_one(struct bnxt *bp, struct bnxt_kctx *kctx, u8 kind, return -EAGAIN; } +#define BNXT_CMD_CTX_RETRY_MAX 10 + +static void bnxt_crypto_timeout(struct bnxt *bp, struct bnxt_tx_ring_info *txr, + struct bnxt_crypto_cmd_ctx *ctx) +{ + int i; + + bnxt_mpc_timeout(bp, txr); + /* Wait for the ctx to complete before proceeding */ + for (i = 0; i < BNXT_CMD_CTX_RETRY_MAX && + !(ctx->status & BNXT_CMD_CTX_COMPLETED); i++) + msleep(20); + if (!(ctx->status & BNXT_CMD_CTX_COMPLETED)) + netdev_warn(bp->dev, + "Timed out waiting for cmd_ctx to complete for MPC ring %d\n", + txr->txq_index); +} + +#define BNXT_XMIT_CRYPTO_RETRY_MAX 10 +#define BNXT_XMIT_CRYPTO_MIN_TMO 100 +#define BNXT_XMIT_CRYPTO_MAX_TMO 150 + +int bnxt_xmit_crypto_cmd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, + void *cmd, unsigned int len, unsigned int tmo) +{ + struct bnxt_crypto_info *crypto = bp->crypto_info; + struct bnxt_crypto_cmd_ctx *ctx = NULL; + unsigned long tmo_left, handle = 0; + int rc, retry = 0; + + if (tmo) { + u32 kid = CE_CMD_KID(cmd); + + ctx = kmem_cache_alloc(crypto->mpc_cache, GFP_KERNEL); + if (!ctx) + return -ENOMEM; + init_completion(&ctx->cmp); + handle = (unsigned long)ctx; + ctx->kid = kid; + ctx->client = txr->tx_ring_struct.mpc_chnl_type; + ctx->status = 0; + retry = BNXT_XMIT_CRYPTO_RETRY_MAX; + might_sleep(); + } + do { + spin_lock_bh(&txr->tx_lock); + rc = bnxt_start_xmit_mpc(bp, txr, cmd, len, handle); + spin_unlock_bh(&txr->tx_lock); + if (rc == -EBUSY && tmo && retry) + usleep_range(BNXT_XMIT_CRYPTO_MIN_TMO, + BNXT_XMIT_CRYPTO_MAX_TMO); + else + break; + } while (retry--); + if (rc || !tmo) + goto xmit_done; + + tmo_left = wait_for_completion_timeout(&ctx->cmp, msecs_to_jiffies(tmo)); + if (!tmo_left) { + netdev_warn(bp->dev, "crypto MP cmd %08x timed out\n", + *((u32 *)cmd)); + bnxt_crypto_timeout(bp, txr, ctx); + rc = -ETIMEDOUT; + goto xmit_done; + } + if (ctx->status == BNXT_CMD_CTX_COMPLETED && + CE_CMPL_STATUS(&ctx->ce_cmp) == CE_CMPL_STATUS_OK) + rc = 0; + else + rc = -EIO; +xmit_done: + if (rc) { + u8 status = ctx ? ctx->status : 0; + + netdev_warn(bp->dev, + "MPC transmit failed, ring idx %d, op 0x%x, kid 0x%x, status 0x%x\n", + txr->bnapi->index, CE_CMD_OP(cmd), CE_CMD_KID(cmd), + status); + } + if (ctx) + kmem_cache_free(crypto->mpc_cache, ctx); + return rc; +} + int bnxt_crypto_init(struct bnxt *bp) { struct bnxt_crypto_info *crypto = bp->crypto_info; @@ -364,3 +470,40 @@ int bnxt_crypto_init(struct bnxt *bp) return 0; } + +void bnxt_crypto_mpc_cmp(struct bnxt *bp, u32 client, unsigned long handle, + struct bnxt_cmpl_entry cmpl[], u32 entries) +{ + struct bnxt_crypto_cmd_ctx *ctx; + struct ce_cmpl *cmp = NULL; + u32 len, kid; + + if (likely(cmpl)) + cmp = cmpl[0].cmpl; + if (!handle || entries != 1) { + if (entries != 1 && cmpl) { + netdev_warn(bp->dev, "Invalid entries %d with handle %lx cmpl %08x in %s()\n", + entries, handle, *(u32 *)cmp, __func__); + } + if (!handle) + return; + } + ctx = (void *)handle; + ctx->status = BNXT_CMD_CTX_COMPLETED; + if (unlikely(!cmpl)) { + ctx->status |= BNXT_CMD_CTX_RESET; + goto cmp_done; + } + kid = CE_CMPL_KID(cmp); + if (ctx->kid != kid || ctx->client != client) { + netdev_warn(bp->dev, + "Invalid CE cmpl 0x%08x for client %d with status 0x%x, expected kid 0x%x and client %d\n", + *(u32 *)cmp, client, ctx->status, ctx->kid, + ctx->client); + ctx->status |= BNXT_CMD_CTX_ERROR; + } + len = min_t(u32, cmpl[0].len, sizeof(ctx->ce_cmp)); + memcpy(&ctx->ce_cmp, cmpl[0].cmpl, len); +cmp_done: + complete(&ctx->cmp); +} diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.h index ecdf18ba6d83..58e52516d932 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_crypto.h @@ -57,6 +57,79 @@ struct bnxt_crypto_info { u16 max_key_ctxs_alloc; struct bnxt_kctx kctx[BNXT_MAX_CRYPTO_KEY_TYPE]; + + struct kmem_cache *mpc_cache; +}; + +struct ce_delete_cmd { + __le32 ctx_kind_kid_opcode; + #define CE_DELETE_CMD_OPCODE_MASK 0xfUL + #define CE_DELETE_CMD_OPCODE_SFT 0 + #define CE_DELETE_CMD_OPCODE_DEL 0x2UL + #define CE_DELETE_CMD_KID_MASK 0xfffff0UL + #define CE_DELETE_CMD_KID_SFT 4 + #define CE_DELETE_CMD_CTX_KIND_MASK 0x1f000000UL + #define CE_DELETE_CMD_CTX_KIND_SFT 24 + #define CE_DELETE_CMD_CTX_KIND_CK_TX (0x11UL << 24) + #define CE_DELETE_CMD_CTX_KIND_CK_RX (0x12UL << 24) +}; + +#define CE_CMD_OP_MASK 0x00000fU +#define CE_CMD_KID_MASK 0xfffff0U +#define CE_CMD_KID_SFT 4 + +#define CE_CMD_OP(cmd_p) \ + (le32_to_cpu(*(__le32 *)(cmd_p)) & CE_CMD_OP_MASK) + +#define CE_CMD_KID(cmd_p) \ + ((le32_to_cpu(*(__le32 *)(cmd_p)) & CE_CMD_KID_MASK) >> CE_CMD_KID_SFT) + +struct ce_cmpl { + __le16 client_subtype_type; + #define CE_CMPL_TYPE_MASK 0x3fUL + #define CE_CMPL_TYPE_SFT 0 + #define CE_CMPL_TYPE_MID_PATH_SHORT 0x1eUL + #define CE_CMPL_SUBTYPE_MASK 0xf00UL + #define CE_CMPL_SUBTYPE_SFT 8 + #define CE_CMPL_SUBTYPE_SOLICITED (0x0UL << 8) + #define CE_CMPL_SUBTYPE_ERR (0x1UL << 8) + #define CE_CMPL_SUBTYPE_RESYNC (0x2UL << 8) + #define CE_CMPL_MP_CLIENT_MASK 0xf000UL + #define CE_CMPL_MP_CLIENT_SFT 12 + #define CE_CMPL_MP_CLIENT_TCE (0x0UL << 12) + #define CE_CMPL_MP_CLIENT_RCE (0x1UL << 12) + __le16 status; + #define CE_CMPL_STATUS_MASK 0xfUL + #define CE_CMPL_STATUS_SFT 0 + #define CE_CMPL_STATUS_OK 0x0UL + #define CE_CMPL_STATUS_CTX_LD_ERR 0x1UL + #define CE_CMPL_STATUS_FID_CHK_ERR 0x2UL + #define CE_CMPL_STATUS_CTX_VER_ERR 0x3UL + #define CE_CMPL_STATUS_DST_ID_ERR 0x4UL + #define CE_CMPL_STATUS_MP_CMD_ERR 0x5UL + u32 opaque; + __le32 v; + #define CE_CMPL_V 0x1UL + __le32 kid; + #define CE_CMPL_KID_MASK 0xfffffUL + #define CE_CMPL_KID_SFT 0 +}; + +#define CE_CMPL_STATUS(ce_cmpl) \ + (le16_to_cpu((ce_cmpl)->status) & CE_CMPL_STATUS_MASK) + +#define CE_CMPL_KID(ce_cmpl) \ + (le32_to_cpu((ce_cmpl)->kid) & CE_CMPL_KID_MASK) + +struct bnxt_crypto_cmd_ctx { + struct completion cmp; + struct ce_cmpl ce_cmp; + u32 kid; + u16 client; + u8 status; +#define BNXT_CMD_CTX_COMPLETED 0x1 +#define BNXT_CMD_CTX_ERROR 0x2 +#define BNXT_CMD_CTX_RESET 0x4 }; #define BNXT_TCK(crypto) ((crypto)->kctx[BNXT_TX_CRYPTO_KEY_TYPE]) @@ -76,7 +149,11 @@ bool bnxt_kid_valid(struct bnxt_kctx *kctx, u32 id); void bnxt_free_one_kctx(struct bnxt_kctx *kctx, u32 id); int bnxt_key_ctx_alloc_one(struct bnxt *bp, struct bnxt_kctx *kctx, u8 kind, u32 *id); +int bnxt_xmit_crypto_cmd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, + void *cmd, unsigned int len, unsigned int tmo); int bnxt_crypto_init(struct bnxt *bp); +void bnxt_crypto_mpc_cmp(struct bnxt *bp, u32 client, unsigned long handle, + struct bnxt_cmpl_entry cmpl[], u32 entries); #else static inline void bnxt_alloc_crypto_info(struct bnxt *bp, struct hwrm_func_qcaps_output *resp) @@ -112,9 +189,24 @@ static inline int bnxt_key_ctx_alloc_one(struct bnxt *bp, return -EOPNOTSUPP; } +static inline int bnxt_xmit_crypto_cmd(struct bnxt *bp, + struct bnxt_tx_ring_info *txr, + void *cmd, unsigned int len, + unsigned int tmo) +{ + return -EOPNOTSUPP; +} + static inline int bnxt_crypto_init(struct bnxt *bp) { return 0; } + +static inline void bnxt_crypto_mpc_cmp(struct bnxt *bp, u32 client, + unsigned long handle, + struct bnxt_cmpl_entry cmpl[], + u32 entries) +{ +} #endif /* CONFIG_BNXT_TLS */ #endif /* BNXT_CRYPTO_H */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c index 67ba43b7f168..196805c2d972 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.c @@ -9,6 +9,7 @@ #include "bnxt.h" #include "bnxt_mpc.h" +#include "bnxt_crypto.h" void bnxt_alloc_mpc_info(struct bnxt *bp, u8 mpc_chnls_cap) { @@ -414,10 +415,27 @@ struct bnxt_tx_ring_info *bnxt_select_mpc_ring(struct bnxt *bp, int ring_type) !mpc->mpc_ring_count[ring_type]) return NULL; - n = smp_processor_id() % mpc->mpc_ring_count[ring_type]; + n = raw_smp_processor_id() % mpc->mpc_ring_count[ring_type]; return &mpc->mpc_rings[ring_type][n]; } +/** + * bnxt_start_xmit_mpc - Transmit message on an MPC ring + * @bp: pointer to bnxt device + * @txr: MPC TX ring structure pointer + * @data: MPC message pointer + * @len: MPC message length + * @handle: Non-zero handle passed back for the completion + * + * This function is called to transmit an MPC message on an MPC TX ring. + * The caller must hold txr->tx_lock. When successful, the HW will return + * a completion and bnxt_crypto_mpc_cmp() will be called with the handle + * passed back. + * + * Return: zero on success, negative error code otherwise: + * ENODEV: MPC TX ring is shutting down. + * EBUSY: MPC TX ring is full + */ int bnxt_start_xmit_mpc(struct bnxt *bp, struct bnxt_tx_ring_info *txr, void *data, unsigned int len, unsigned long handle) { @@ -470,6 +488,151 @@ int bnxt_start_xmit_mpc(struct bnxt *bp, struct bnxt_tx_ring_info *txr, return 0; } +/* Returns true if the ring is successfully marked as closing. */ +static bool bnxt_disable_mpc_ring(struct bnxt_mpc_info *mpc, int mpc_ring) +{ + struct bnxt_tx_ring_info *txr; + bool disabled = false; + int i; + + for (i = 0; i < BNXT_MPC_TYPE_MAX; i++) { + if (mpc_ring >= mpc->mpc_ring_count[i]) + continue; + txr = &mpc->mpc_rings[i][mpc_ring]; + spin_lock_bh(&txr->tx_lock); + if (!READ_ONCE(txr->dev_state)) { + disabled = true; + WRITE_ONCE(txr->dev_state, BNXT_DEV_STATE_CLOSING); + } + spin_unlock_bh(&txr->tx_lock); + if (!disabled) + break; + } + return disabled; +} + +static void bnxt_enable_mpc_ring(struct bnxt_mpc_info *mpc, int mpc_ring) +{ + struct bnxt_tx_ring_info *txr; + int i; + + for (i = 0; i < BNXT_MPC_TYPE_MAX; i++) { + if (mpc_ring >= mpc->mpc_ring_count[i]) + continue; + txr = &mpc->mpc_rings[i][mpc_ring]; + WRITE_ONCE(txr->dev_state, 0); + } +} + +static void bnxt_clear_one_mpc_entries(struct bnxt *bp, + struct bnxt_tx_ring_info *txr) +{ + struct bnxt_sw_mpc_tx_bd *tx_buf; + unsigned long handle; + int i, max_idx; + u32 client; + + max_idx = bp->tx_nr_pages * TX_DESC_CNT; + + for (i = 0; i < max_idx; i++) { + tx_buf = &txr->tx_mpc_buf_ring[i]; + handle = tx_buf->handle; + if (handle) { + client = txr->tx_ring_struct.mpc_chnl_type; + bnxt_crypto_mpc_cmp(bp, client, handle, NULL, 0); + tx_buf->handle = 0; + } + } +} + +static void bnxt_mpc_ring_stop(struct bnxt *bp, struct bnxt_mpc_info *mpc, + int mpc_ring) +{ + struct bnxt_tx_ring_info *txr; + struct bnxt_cp_ring_info *cpr; + int i; + + for (i = 0; i < BNXT_MPC_TYPE_MAX; i++) { + if (mpc->mpc_ring_count[i] > mpc_ring) { + txr = &mpc->mpc_rings[i][mpc_ring]; + bnxt_hwrm_tx_ring_free(bp, txr, true); + } + } + /* CP rings must be freed at the end to guarantee that the HWRM_DONE + * responses for HWRM_RING_FREE can still be seen on the CP rings. + */ + for (i = 0; i < BNXT_MPC_TYPE_MAX; i++) { + if (mpc->mpc_ring_count[i] > mpc_ring) { + txr = &mpc->mpc_rings[i][mpc_ring]; + cpr = txr->tx_cpr; + if (cpr) { + bnxt_hwrm_cp_ring_free(bp, cpr); + bnxt_clear_one_cp_ring(bp, cpr); + } + bnxt_clear_one_mpc_entries(bp, txr); + } + } +} + +static int bnxt_mpc_ring_start(struct bnxt *bp, struct bnxt_mpc_info *mpc, + int mpc_ring) +{ + struct bnxt_tx_ring_info *txr; + int i, rc; + + for (i = 0; i < BNXT_MPC_TYPE_MAX; i++) { + if (mpc->mpc_ring_count[i] > mpc_ring) { + txr = &mpc->mpc_rings[i][mpc_ring]; + txr->tx_prod = 0; + txr->tx_cons = 0; + txr->tx_hw_cons = 0; + rc = bnxt_hwrm_one_mpc_ring_alloc(bp, txr); + if (rc) + return rc; + } + } + return 0; +} + +static int bnxt_mpc_ring_reset(struct bnxt *bp, int mpc_ring) +{ + struct bnxt_mpc_info *mpc = bp->mpc_info; + int rc; + + if (!mpc) + return 0; + if (mpc_ring >= mpc->mpc_cp_rings) + return -EINVAL; + + if (!bnxt_disable_mpc_ring(mpc, mpc_ring)) + return 0; + + netdev_warn(bp->dev, "Resetting MPC ring %d\n", mpc_ring); + netdev_lock(bp->dev); + bnxt_mpc_ring_stop(bp, mpc, mpc_ring); + + rc = bnxt_mpc_ring_start(bp, mpc, mpc_ring); + if (rc) { + netdev_err(bp->dev, "Error starting MPC ring %d, rc: %d, resetting device\n", + mpc_ring, rc); + bnxt_mpc_ring_stop(bp, mpc, mpc_ring); + bnxt_reset_task(bp, true); + netdev_unlock(bp->dev); + /* Return here as bnxt_reset_task() will clear everything */ + return rc; + } + netdev_unlock(bp->dev); + bnxt_enable_mpc_ring(mpc, mpc_ring); + return 0; +} + +int bnxt_mpc_timeout(struct bnxt *bp, struct bnxt_tx_ring_info *txr) +{ + if (txr->tx_ring_struct.queue_id == BNXT_MPC_QUEUE_ID) + return bnxt_mpc_ring_reset(bp, txr->txq_index); + return -EINVAL; +} + static bool bnxt_mpc_unsolicit(struct mpc_cmp *mpcmp) { u32 client = MPC_CMP_CLIENT_TYPE(mpcmp); @@ -486,6 +649,7 @@ int bnxt_mpc_cmp(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u32 *raw_cons) u16 cons = RING_CMP(*raw_cons); struct mpc_cmp *mpcmp, *mpcmp1; u32 tmp_raw_cons = *raw_cons; + unsigned long handle = 0; u32 client, cmpl_num; u8 type; @@ -529,14 +693,17 @@ int bnxt_mpc_cmp(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u32 *raw_cons) txr = bnapi->tx_mpc_ring[client]; tx_cons = txr->tx_cons; if (TX_OPAQUE_RING(opaque) != txr->tx_napi_idx) - netdev_warn(bp->dev, "Wrong opaque %x, expected ring %x, idx %x\n", + netdev_warn(bp->dev, "Wrong opaque %x, expected ring %x, cons idx %x\n", opaque, txr->tx_napi_idx, txr->tx_cons); mpc_buf = &txr->tx_mpc_buf_ring[RING_TX(bp, tx_cons)]; + if (!READ_ONCE(txr->dev_state)) + handle = mpc_buf->handle; mpc_buf->handle = 0; tx_cons += mpc_buf->inline_bds; txr->tx_cons = tx_cons; txr->tx_hw_cons = RING_TX(bp, tx_cons); } + bnxt_crypto_mpc_cmp(bp, client, handle, cmpl_entry_arr, cmpl_num); cmp_done: *raw_cons = tmp_raw_cons; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h index 9958d1749ffb..95ceb02b7cf6 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_mpc.h @@ -22,6 +22,8 @@ enum bnxt_mpc_type { #define BNXT_DFLT_MPC_TCE BNXT_MAX_MPC #define BNXT_DFLT_MPC_RCE BNXT_MAX_MPC +#define BNXT_MPC_TMO_MSECS 1000 + struct bnxt_mpc_info { u8 mpc_chnls_cap; u8 mpc_cp_rings; @@ -106,6 +108,7 @@ void bnxt_hwrm_mpc_ring_free(struct bnxt *bp, bool close_path); struct bnxt_tx_ring_info *bnxt_select_mpc_ring(struct bnxt *bp, int ring_type); int bnxt_start_xmit_mpc(struct bnxt *bp, struct bnxt_tx_ring_info *txr, void *data, unsigned int len, unsigned long handle); +int bnxt_mpc_timeout(struct bnxt *bp, struct bnxt_tx_ring_info *txr); int bnxt_mpc_cmp(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u32 *raw_cons); #else static inline void bnxt_alloc_mpc_info(struct bnxt *bp, u8 mpc_chnls_cap) @@ -192,6 +195,12 @@ static inline int bnxt_start_xmit_mpc(struct bnxt *bp, return -EOPNOTSUPP; } +static inline int bnxt_mpc_timeout(struct bnxt *bp, + struct bnxt_tx_ring_info *txr) +{ + return -EOPNOTSUPP; +} + static inline int bnxt_mpc_cmp(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, u32 *raw_cons) { -- 2.51.0