svn commit: r239338 - in head/sys/dev/cxgbe: . tom
Navdeep Parhar
np at FreeBSD.org
Thu Aug 16 20:15:29 UTC 2012
Author: np
Date: Thu Aug 16 20:15:29 2012
New Revision: 239338
URL: http://svn.freebsd.org/changeset/base/239338
Log:
Add a routine (t4_set_tcb_field) to update arbitrary parts of a hardware
TCB. Filters are programmed by modifying the TCB too (via a different
routine) and the reply to any TCB update is delivered via a
CPL_SET_TCB_RPL. Figure out whether the reply is for a filter-write or
something else and route it appropriately.
MFC after: 2 weeks
Modified:
head/sys/dev/cxgbe/adapter.h
head/sys/dev/cxgbe/t4_main.c
head/sys/dev/cxgbe/tom/t4_cpl_io.c
head/sys/dev/cxgbe/tom/t4_tom.h
Modified: head/sys/dev/cxgbe/adapter.h
==============================================================================
--- head/sys/dev/cxgbe/adapter.h Thu Aug 16 19:22:34 2012 (r239337)
+++ head/sys/dev/cxgbe/adapter.h Thu Aug 16 20:15:29 2012 (r239338)
@@ -744,6 +744,7 @@ void t4_iterate(void (*)(struct adapter
int t4_register_cpl_handler(struct adapter *, int, cpl_handler_t);
int t4_register_an_handler(struct adapter *, an_handler_t);
int t4_register_fw_msg_handler(struct adapter *, int, fw_msg_handler_t);
+int t4_filter_rpl(struct sge_iq *, const struct rss_header *, struct mbuf *);
/* t4_sge.c */
void t4_sge_modload(void);
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Thu Aug 16 19:22:34 2012 (r239337)
+++ head/sys/dev/cxgbe/t4_main.c Thu Aug 16 20:15:29 2012 (r239338)
@@ -346,8 +346,6 @@ static int del_filter(struct adapter *,
static void clear_filter(struct filter_entry *);
static int set_filter_wr(struct adapter *, int);
static int del_filter_wr(struct adapter *, int);
-static int filter_rpl(struct sge_iq *, const struct rss_header *,
- struct mbuf *);
static int get_sge_context(struct adapter *, struct t4_sge_context *);
static int read_card_mem(struct adapter *, struct t4_mem_range *);
#ifdef TCP_OFFLOAD
@@ -465,7 +463,7 @@ t4_attach(device_t dev)
sc->cpl_handler[i] = cpl_not_handled;
for (i = 0; i < ARRAY_SIZE(sc->fw_msg_handler); i++)
sc->fw_msg_handler[i] = fw_msg_not_handled;
- t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, filter_rpl);
+ t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, t4_filter_rpl);
/* Prepare the adapter for operation */
rc = -t4_prep_adapter(sc);
@@ -5000,8 +4998,8 @@ del_filter_wr(struct adapter *sc, int fi
return (0);
}
-static int
-filter_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
+int
+t4_filter_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
{
struct adapter *sc = iq->adapter;
const struct cpl_set_tcb_rpl *rpl = (const void *)(rss + 1);
Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c Thu Aug 16 19:22:34 2012 (r239337)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c Thu Aug 16 20:15:29 2012 (r239338)
@@ -1262,6 +1262,51 @@ do_fw4_ack(struct sge_iq *iq, const stru
return (0);
}
+static int
+do_set_tcb_rpl(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
+{
+ struct adapter *sc = iq->adapter;
+ const struct cpl_set_tcb_rpl *cpl = (const void *)(rss + 1);
+ unsigned int tid = GET_TID(cpl);
+#ifdef INVARIANTS
+ unsigned int opcode = G_CPL_OPCODE(be32toh(OPCODE_TID(cpl)));
+#endif
+
+ KASSERT(opcode == CPL_SET_TCB_RPL,
+ ("%s: unexpected opcode 0x%x", __func__, opcode));
+ KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__));
+
+ if (tid >= sc->tids.ftid_base &&
+ tid < sc->tids.ftid_base + sc->tids.nftids)
+ return (t4_filter_rpl(iq, rss, m)); /* TCB is a filter */
+
+ CXGBE_UNIMPLEMENTED(__func__);
+}
+
+void
+t4_set_tcb_field(struct adapter *sc, struct toepcb *toep, uint16_t word,
+ uint64_t mask, uint64_t val)
+{
+ struct wrqe *wr;
+ struct cpl_set_tcb_field *req;
+
+ wr = alloc_wrqe(sizeof(*req), toep->ctrlq);
+ if (wr == NULL) {
+ /* XXX */
+ panic("%s: allocation failure.", __func__);
+ }
+ req = wrtod(wr);
+
+ INIT_TP_WR_MIT_CPL(req, CPL_SET_TCB_FIELD, toep->tid);
+ req->reply_ctrl = htobe16(V_NO_REPLY(1) |
+ V_QUEUENO(toep->ofld_rxq->iq.abs_id));
+ req->word_cookie = htobe16(V_WORD(word) | V_COOKIE(0));
+ req->mask = htobe64(mask);
+ req->val = htobe64(val);
+
+ t4_wrq_tx(sc, wr);
+}
+
void
t4_init_cpl_io_handlers(struct adapter *sc)
{
@@ -1272,5 +1317,13 @@ t4_init_cpl_io_handlers(struct adapter *
t4_register_cpl_handler(sc, CPL_ABORT_RPL_RSS, do_abort_rpl);
t4_register_cpl_handler(sc, CPL_RX_DATA, do_rx_data);
t4_register_cpl_handler(sc, CPL_FW4_ACK, do_fw4_ack);
+ t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, do_set_tcb_rpl);
+}
+
+void
+t4_uninit_cpl_io_handlers(struct adapter *sc)
+{
+
+ t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, t4_filter_rpl);
}
#endif
Modified: head/sys/dev/cxgbe/tom/t4_tom.h
==============================================================================
--- head/sys/dev/cxgbe/tom/t4_tom.h Thu Aug 16 19:22:34 2012 (r239337)
+++ head/sys/dev/cxgbe/tom/t4_tom.h Thu Aug 16 20:15:29 2012 (r239338)
@@ -236,6 +236,7 @@ void t4_offload_socket(struct toedev *,
/* t4_cpl_io.c */
void t4_init_cpl_io_handlers(struct adapter *);
+void t4_uninit_cpl_io_handlers(struct adapter *);
void send_abort_rpl(struct adapter *, struct sge_wrq *, int , int);
void send_flowc_wr(struct toepcb *, struct flowc_tx_params *);
void send_reset(struct adapter *, struct toepcb *, uint32_t);
@@ -244,5 +245,7 @@ void t4_rcvd(struct toedev *, struct tcp
int t4_tod_output(struct toedev *, struct tcpcb *);
int t4_send_fin(struct toedev *, struct tcpcb *);
int t4_send_rst(struct toedev *, struct tcpcb *);
+void t4_set_tcb_field(struct adapter *, struct toepcb *, uint16_t, uint64_t,
+ uint64_t);
#endif
More information about the svn-src-all
mailing list