aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavdeep Parhar <np@FreeBSD.org>2022-04-14 22:49:58 +0000
committerNavdeep Parhar <np@FreeBSD.org>2023-02-02 07:13:55 +0000
commitf9cc817c17b7663e80d5418362d2da0be2c7a2a1 (patch)
tree21e479a987ba94698b59b662c796a91d06e2709f
parent5d45caebfad60cd323b732d99e52239644a724a0 (diff)
downloadsrc-f9cc817c17b7663e80d5418362d2da0be2c7a2a1.tar.gz
src-f9cc817c17b7663e80d5418362d2da0be2c7a2a1.zip
cxgbe/t4_tom: Support for round-robin selection of offload queues.
A COP (Connection Offload Policy) rule can now specify that the tx and/or rx queue for a new tid should be selected in a round-robin manner. There is no change in default behavior. Reviewed by: jhb@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D34921 (cherry picked from commit db28d4a0cd1c7a8505d6cbb3e8772b794cd55e53)
-rw-r--r--sys/dev/cxgbe/adapter.h2
-rw-r--r--sys/dev/cxgbe/t4_ioctl.h5
-rw-r--r--sys/dev/cxgbe/tom/t4_tom.c22
3 files changed, 21 insertions, 8 deletions
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index b3bffcc32b52..f59fe4e7c4e4 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -255,6 +255,8 @@ struct vi_info {
struct sysctl_oid *ofld_txq_oid;
uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */
+ u_int txq_rr;
+ u_int rxq_rr;
};
struct tx_ch_rl_params {
diff --git a/sys/dev/cxgbe/t4_ioctl.h b/sys/dev/cxgbe/t4_ioctl.h
index f3bb7d8b4aa4..3ef03f7c526c 100644
--- a/sys/dev/cxgbe/t4_ioctl.h
+++ b/sys/dev/cxgbe/t4_ioctl.h
@@ -376,6 +376,11 @@ enum {
OPEN_TYPE_DONTCARE = 'D',
};
+enum {
+ QUEUE_RANDOM = -1,
+ QUEUE_ROUNDROBIN = -2,
+};
+
struct offload_settings {
int8_t offload;
int8_t rx_coalesce;
diff --git a/sys/dev/cxgbe/tom/t4_tom.c b/sys/dev/cxgbe/tom/t4_tom.c
index b36b4b934d12..8888265dd32a 100644
--- a/sys/dev/cxgbe/tom/t4_tom.c
+++ b/sys/dev/cxgbe/tom/t4_tom.c
@@ -1217,17 +1217,23 @@ init_conn_params(struct vi_info *vi , struct offload_settings *s,
cp->mtu_idx = find_best_mtu_idx(sc, inc, s);
/* Tx queue for this connection. */
- if (s->txq >= 0 && s->txq < vi->nofldtxq)
- cp->txq_idx = s->txq;
+ if (s->txq == QUEUE_RANDOM)
+ cp->txq_idx = arc4random();
+ else if (s->txq == QUEUE_ROUNDROBIN)
+ cp->txq_idx = atomic_fetchadd_int(&vi->txq_rr, 1);
else
- cp->txq_idx = arc4random() % vi->nofldtxq;
+ cp->txq_idx = s->txq;
+ cp->txq_idx %= vi->nofldtxq;
cp->txq_idx += vi->first_ofld_txq;
/* Rx queue for this connection. */
- if (s->rxq >= 0 && s->rxq < vi->nofldrxq)
- cp->rxq_idx = s->rxq;
+ if (s->rxq == QUEUE_RANDOM)
+ cp->rxq_idx = arc4random();
+ else if (s->rxq == QUEUE_ROUNDROBIN)
+ cp->rxq_idx = atomic_fetchadd_int(&vi->rxq_rr, 1);
else
- cp->rxq_idx = arc4random() % vi->nofldrxq;
+ cp->rxq_idx = s->rxq;
+ cp->rxq_idx %= vi->nofldrxq;
cp->rxq_idx += vi->first_ofld_rxq;
if (SOLISTENING(so)) {
@@ -1587,8 +1593,8 @@ lookup_offload_policy(struct adapter *sc, int open_type, struct mbuf *m,
.ecn = -1,
.ddp = -1,
.tls = -1,
- .txq = -1,
- .rxq = -1,
+ .txq = QUEUE_RANDOM,
+ .rxq = QUEUE_RANDOM,
.mss = -1,
};
static const struct offload_settings disallow_offloading_settings = {