From 111638bf6896d5100ace4d14c1ff45eaaec164d0 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Mon, 30 Apr 2018 21:47:30 +0000 Subject: [PATCH] cxgbe(4): Convert ACT_OPEN_RPL to a shared CPL. Reserve 3b in the 14b atid to identify the owner and use it to dispatch the CPL. This allows all CPLs that use an atid to be used as shared CPLs, although ACT_OPEN_RPL is the only one being converted in this revision. Sponsored by: Chelsio Communications --- sys/dev/cxgbe/common/t4_msg.h | 7 ++++++- sys/dev/cxgbe/offload.h | 5 +++-- sys/dev/cxgbe/t4_main.c | 1 + sys/dev/cxgbe/t4_sge.c | 18 ++++++++++++++++++ sys/dev/cxgbe/tom/t4_connect.c | 8 +++++--- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/sys/dev/cxgbe/common/t4_msg.h b/sys/dev/cxgbe/common/t4_msg.h index 599ad428cf5b..c67306750164 100644 --- a/sys/dev/cxgbe/common/t4_msg.h +++ b/sys/dev/cxgbe/common/t4_msg.h @@ -308,10 +308,15 @@ union opcode_tid { /* partitioning of TID fields that also carry a queue id */ #define S_TID_TID 0 -#define M_TID_TID 0x3fff +#define M_TID_TID 0x7ff #define V_TID_TID(x) ((x) << S_TID_TID) #define G_TID_TID(x) (((x) >> S_TID_TID) & M_TID_TID) +#define S_TID_COOKIE 11 +#define M_TID_COOKIE 0x7 +#define V_TID_COOKIE(x) ((x) << S_TID_COOKIE) +#define G_TID_COOKIE(x) (((x) >> S_TID_COOKIE) & M_TID_COOKIE) + #define S_TID_QID 14 #define M_TID_QID 0x3ff #define V_TID_QID(x) ((x) << S_TID_QID) diff --git a/sys/dev/cxgbe/offload.h b/sys/dev/cxgbe/offload.h index cd27d7de6e24..15981910c644 100644 --- a/sys/dev/cxgbe/offload.h +++ b/sys/dev/cxgbe/offload.h @@ -66,9 +66,10 @@ struct stid_region { }; /* - * Max # of ATIDs. The absolute HW max is 16K but we keep it lower. + * Max # of ATIDs. The absolute HW max is 14b (enough for 16K) but we reserve + * the upper 3b for use as a cookie to demux the reply. */ -#define MAX_ATIDS 8192U +#define MAX_ATIDS 2048U union aopen_entry { void *data; diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index aa30a8a45682..19d04f0956be 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2504,6 +2504,7 @@ alloc_atid(struct adapter *sc, void *ctx) union aopen_entry *p = t->afree; atid = p - t->atid_tab; + MPASS(atid <= M_TID_TID); t->afree = p->next; p->data = ctx; t->atids_in_use++; diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index a444674db1bf..46458928ad66 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -287,6 +287,7 @@ fw_msg_handler_t t4_fw_msg_handler[NUM_FW6_TYPES]; cpl_handler_t t4_cpl_handler[NUM_CPL_CMDS]; cpl_handler_t set_tcb_rpl_handlers[NUM_CPL_COOKIES]; cpl_handler_t l2t_write_rpl_handlers[NUM_CPL_COOKIES]; +cpl_handler_t act_open_rpl_handlers[NUM_CPL_COOKIES]; void t4_register_an_handler(an_handler_t h) @@ -370,12 +371,26 @@ l2t_write_rpl_handler(struct sge_iq *iq, const struct rss_header *rss, return (l2t_write_rpl_handlers[cookie](iq, rss, m)); } +static int +act_open_rpl_handler(struct sge_iq *iq, const struct rss_header *rss, + struct mbuf *m) +{ + const struct cpl_act_open_rpl *cpl = (const void *)(rss + 1); + u_int cookie = G_TID_COOKIE(G_AOPEN_ATID(be32toh(cpl->atid_status))); + + MPASS(m == NULL); + MPASS(cookie != CPL_COOKIE_RESERVED); + + return (act_open_rpl_handlers[cookie](iq, rss, m)); +} + static void t4_init_shared_cpl_handlers(void) { t4_register_cpl_handler(CPL_SET_TCB_RPL, set_tcb_rpl_handler); t4_register_cpl_handler(CPL_L2T_WRITE_RPL, l2t_write_rpl_handler); + t4_register_cpl_handler(CPL_ACT_OPEN_RPL, act_open_rpl_handler); } void @@ -395,6 +410,9 @@ t4_register_shared_cpl_handler(int opcode, cpl_handler_t h, int cookie) case CPL_L2T_WRITE_RPL: loc = (uintptr_t *)&l2t_write_rpl_handlers[cookie]; break; + case CPL_ACT_OPEN_RPL: + loc = (uintptr_t *)&act_open_rpl_handlers[cookie]; + break; default: MPASS(0); return; diff --git a/sys/dev/cxgbe/tom/t4_connect.c b/sys/dev/cxgbe/tom/t4_connect.c index 032e540dce58..3df327d68365 100644 --- a/sys/dev/cxgbe/tom/t4_connect.c +++ b/sys/dev/cxgbe/tom/t4_connect.c @@ -281,7 +281,8 @@ t4_init_connect_cpl_handlers(void) { t4_register_cpl_handler(CPL_ACT_ESTABLISH, do_act_establish); - t4_register_cpl_handler(CPL_ACT_OPEN_RPL, do_act_open_rpl); + t4_register_shared_cpl_handler(CPL_ACT_OPEN_RPL, do_act_open_rpl, + CPL_COOKIE_TOM); } void @@ -289,7 +290,7 @@ t4_uninit_connect_cpl_handlers(void) { t4_register_cpl_handler(CPL_ACT_ESTABLISH, NULL); - t4_register_cpl_handler(CPL_ACT_OPEN_RPL, NULL); + t4_register_shared_cpl_handler(CPL_ACT_OPEN_RPL, NULL, CPL_COOKIE_TOM); } #define DONT_OFFLOAD_ACTIVE_OPEN(x) do { \ @@ -418,7 +419,8 @@ t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt, else rscale = 0; mtu_idx = find_best_mtu_idx(sc, &inp->inp_inc, &settings); - qid_atid = V_TID_QID(toep->ofld_rxq->iq.abs_id) | V_TID_TID(toep->tid); + qid_atid = V_TID_QID(toep->ofld_rxq->iq.abs_id) | V_TID_TID(toep->tid) | + V_TID_COOKIE(CPL_COOKIE_TOM); if (isipv6) { struct cpl_act_open_req6 *cpl = wrtod(wr);