cxgbe(4): Track the state of the hardware traffic schedulers in the

driver.  This works as long as everyone uses set_sched_class_params
to program them.

Sponsored by:	Chelsio Communications
This commit is contained in:
Navdeep Parhar 2016-06-07 00:27:55 +00:00
parent 2d5ad99a0d
commit 46464b95b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=301535
2 changed files with 30 additions and 0 deletions

View File

@ -54,6 +54,7 @@
#include <netinet/tcp_lro.h>
#include "offload.h"
#include "t4_ioctl.h"
#include "common/t4_msg.h"
#include "firmware/t4fw_interface.h"
@ -264,6 +265,17 @@ struct vi_info {
uint8_t hw_addr[ETHER_ADDR_LEN]; /* factory MAC address, won't change */
};
enum {
/* tx_sched_class flags */
TX_SC_OK = (1 << 0), /* Set up in hardware, active. */
};
struct tx_sched_class {
int refcount;
int flags;
struct t4_sched_class_params params;
};
struct port_info {
device_t dev;
struct adapter *adapter;
@ -273,6 +285,8 @@ struct port_info {
int up_vis;
int uld_vis;
struct tx_sched_class *tc; /* traffic classes for this channel */
struct mtx pi_lock;
char lockname[16];
unsigned long flags;

View File

@ -875,6 +875,9 @@ t4_attach(device_t dev)
mtx_init(&pi->pi_lock, pi->lockname, 0, MTX_DEF);
sc->chan_map[pi->tx_chan] = i;
pi->tc = malloc(sizeof(struct tx_sched_class) *
sc->chip_params->nsched_cls, M_CXGBE, M_ZERO | M_WAITOK);
if (is_10G_port(pi) || is_40G_port(pi)) {
n10g++;
for_each_vi(pi, j, vi) {
@ -1131,6 +1134,7 @@ t4_detach(device_t dev)
mtx_destroy(&pi->pi_lock);
free(pi->vi, M_CXGBE);
free(pi->tc, M_CXGBE);
free(pi, M_CXGBE);
}
}
@ -8319,6 +8323,7 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p,
{
int rc, top_speed, fw_level, fw_mode, fw_rateunit, fw_ratemode;
struct port_info *pi;
struct tx_sched_class *tc;
if (p->level == SCHED_CLASS_LEVEL_CL_RL)
fw_level = FW_SCHED_PARAMS_LEVEL_CL_RL;
@ -8401,9 +8406,20 @@ set_sched_class_params(struct adapter *sc, struct t4_sched_class_params *p,
sleep_ok ? (SLEEP_OK | INTR_OK) : HOLD_LOCK, "t4sscp");
if (rc)
return (rc);
tc = &pi->tc[p->cl];
tc->params = *p;
rc = -t4_sched_params(sc, FW_SCHED_TYPE_PKTSCHED, fw_level, fw_mode,
fw_rateunit, fw_ratemode, p->channel, p->cl, p->minrate, p->maxrate,
p->weight, p->pktsize, sleep_ok);
if (rc == 0)
tc->flags |= TX_SC_OK;
else {
/*
* Unknown state at this point, see tc->params for what was
* attempted.
*/
tc->flags &= ~TX_SC_OK;
}
end_synchronized_op(sc, sleep_ok ? 0 : LOCK_HELD);
return (rc);