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@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34921
This commit is contained in:
Navdeep Parhar 2022-04-14 15:49:58 -07:00
parent 169e94c41e
commit db28d4a0cd
3 changed files with 21 additions and 8 deletions

View File

@ -254,6 +254,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 {

View File

@ -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;

View File

@ -1377,17 +1377,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)) {
@ -1747,8 +1753,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 = {