diff --git a/utils/mqnic.c b/utils/mqnic.c index 777960df8..2e3126d1c 100644 --- a/utils/mqnic.c +++ b/utils/mqnic.c @@ -125,6 +125,22 @@ struct mqnic *mqnic_open(const char *dev_name) interface->rx_queue_count = MQNIC_MAX_RX_RINGS; if (interface->rx_cpl_queue_count > MQNIC_MAX_RX_CPL_RINGS) interface->rx_cpl_queue_count = MQNIC_MAX_RX_CPL_RINGS; + + if (interface->port_count > MQNIC_MAX_PORTS) + interface->port_count = MQNIC_MAX_PORTS; + + for (int l = 0; l < interface->port_count; l++) + { + struct mqnic_port *port = &interface->ports[l]; + port->regs = interface->regs + interface->port_offset + interface->port_stride*l; + + port->port_id = mqnic_reg_read32(port->regs, MQNIC_PORT_REG_PORT_ID); + + port->sched_count = mqnic_reg_read32(port->regs, MQNIC_PORT_REG_SCHED_COUNT); + port->sched_offset = mqnic_reg_read32(port->regs, MQNIC_PORT_REG_SCHED_OFFSET); + port->sched_stride = mqnic_reg_read32(port->regs, MQNIC_PORT_REG_SCHED_STRIDE); + port->sched_type = mqnic_reg_read32(port->regs, MQNIC_PORT_REG_SCHED_TYPE); + } } return dev; diff --git a/utils/mqnic.h b/utils/mqnic.h index 1b7c54a55..e852d0cab 100644 --- a/utils/mqnic.h +++ b/utils/mqnic.h @@ -45,6 +45,20 @@ either expressed or implied, of The Regents of the University of California. struct mqnic; +struct mqnic_port { + struct mqnic *mqnic; + struct mqnic_if *mqnic_if; + + volatile uint8_t *regs; + + uint32_t port_id; + + uint32_t sched_count; + uint32_t sched_offset; + uint32_t sched_stride; + uint32_t sched_type; +}; + struct mqnic_if { struct mqnic *mqnic; @@ -67,6 +81,8 @@ struct mqnic_if { uint32_t port_count; uint32_t port_offset; uint32_t port_stride; + + struct mqnic_port ports[MQNIC_MAX_PORTS]; }; struct mqnic {