Report NTB link speed to console and interface.
MFC after: 2 weeks
This commit is contained in:
parent
bfbcb15f76
commit
48c4767756
@ -225,6 +225,7 @@ ntb_net_init(void *arg)
|
||||
if_t ifp = sc->ifp;
|
||||
|
||||
if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE);
|
||||
if_setbaudrate(ifp, ntb_transport_link_speed(sc->queues[0].qp));
|
||||
if_link_state_change(ifp, ntb_transport_link_query(sc->queues[0].qp) ?
|
||||
LINK_STATE_UP : LINK_STATE_DOWN);
|
||||
}
|
||||
@ -474,20 +475,10 @@ static void
|
||||
ntb_net_event_handler(void *data, enum ntb_link_event status)
|
||||
{
|
||||
struct ntb_net_queue *q = data;
|
||||
int new_state;
|
||||
|
||||
switch (status) {
|
||||
case NTB_LINK_DOWN:
|
||||
new_state = LINK_STATE_DOWN;
|
||||
break;
|
||||
case NTB_LINK_UP:
|
||||
new_state = LINK_STATE_UP;
|
||||
break;
|
||||
default:
|
||||
new_state = LINK_STATE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
if_link_state_change(q->ifp, new_state);
|
||||
if_setbaudrate(q->ifp, ntb_transport_link_speed(q->qp));
|
||||
if_link_state_change(q->ifp, (status == NTB_LINK_UP) ? LINK_STATE_UP :
|
||||
LINK_STATE_DOWN);
|
||||
}
|
||||
|
||||
/* Helper functions */
|
||||
|
@ -168,7 +168,15 @@ ntb_link_event(device_t dev)
|
||||
struct ntb_child **cpp = device_get_softc(dev);
|
||||
struct ntb_child *nc;
|
||||
struct rm_priotracker ctx_tracker;
|
||||
enum ntb_speed speed;
|
||||
enum ntb_width width;
|
||||
|
||||
if (NTB_LINK_IS_UP(dev, &speed, &width)) {
|
||||
device_printf(dev, "Link is up (PCIe %d.x / x%d)\n",
|
||||
(int)speed, (int)width);
|
||||
} else {
|
||||
device_printf(dev, "Link is down\n");
|
||||
}
|
||||
for (nc = *cpp; nc != NULL; nc = nc->next) {
|
||||
rm_rlock(&nc->ctx_lock, &ctx_tracker);
|
||||
if (nc->ctx_ops != NULL && nc->ctx_ops->link_event != NULL)
|
||||
|
@ -38,6 +38,7 @@ HEADER {
|
||||
NTB_SPEED_GEN1 = 1,
|
||||
NTB_SPEED_GEN2 = 2,
|
||||
NTB_SPEED_GEN3 = 3,
|
||||
NTB_SPEED_GEN4 = 4,
|
||||
};
|
||||
|
||||
enum ntb_width {
|
||||
|
@ -202,6 +202,8 @@ struct ntb_transport_ctx {
|
||||
unsigned qp_count;
|
||||
uint64_t qp_bitmap;
|
||||
volatile bool link_is_up;
|
||||
enum ntb_speed link_speed;
|
||||
enum ntb_width link_width;
|
||||
struct callout link_work;
|
||||
struct callout link_watchdog;
|
||||
struct task link_cleanup;
|
||||
@ -1024,7 +1026,7 @@ ntb_transport_event_callback(void *data)
|
||||
{
|
||||
struct ntb_transport_ctx *nt = data;
|
||||
|
||||
if (ntb_link_is_up(nt->dev, NULL, NULL)) {
|
||||
if (ntb_link_is_up(nt->dev, &nt->link_speed, &nt->link_width)) {
|
||||
ntb_printf(1, "HW link up\n");
|
||||
callout_reset(&nt->link_work, 0, ntb_transport_link_work, nt);
|
||||
} else {
|
||||
@ -1105,7 +1107,7 @@ ntb_transport_link_work(void *arg)
|
||||
for (i = 0; i < nt->mw_count; i++)
|
||||
ntb_free_mw(nt, i);
|
||||
out:
|
||||
if (ntb_link_is_up(dev, NULL, NULL))
|
||||
if (ntb_link_is_up(dev, &nt->link_speed, &nt->link_width))
|
||||
callout_reset(&nt->link_work,
|
||||
NTB_LINK_DOWN_TIMEOUT * hz / 1000, ntb_transport_link_work, nt);
|
||||
}
|
||||
@ -1379,6 +1381,43 @@ ntb_transport_link_query(struct ntb_transport_qp *qp)
|
||||
return (qp->link_is_up);
|
||||
}
|
||||
|
||||
/**
|
||||
* ntb_transport_link_speed - Query transport link speed
|
||||
* @qp: NTB transport layer queue to be queried
|
||||
*
|
||||
* Query connection speed to the remote system of the NTB transport queue
|
||||
*
|
||||
* RETURNS: link speed in bits per second
|
||||
*/
|
||||
uint64_t
|
||||
ntb_transport_link_speed(struct ntb_transport_qp *qp)
|
||||
{
|
||||
struct ntb_transport_ctx *nt = qp->transport;
|
||||
uint64_t rate;
|
||||
|
||||
if (!nt->link_is_up)
|
||||
return (0);
|
||||
switch (nt->link_speed) {
|
||||
case NTB_SPEED_GEN1:
|
||||
rate = 2500000000 * 8 / 10;
|
||||
break;
|
||||
case NTB_SPEED_GEN2:
|
||||
rate = 5000000000 * 8 / 10;
|
||||
break;
|
||||
case NTB_SPEED_GEN3:
|
||||
rate = 8000000000 * 128 / 130;
|
||||
break;
|
||||
case NTB_SPEED_GEN4:
|
||||
rate = 16000000000 * 128 / 130;
|
||||
break;
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
if (nt->link_width <= 0)
|
||||
return (0);
|
||||
return (rate * nt->link_width);
|
||||
}
|
||||
|
||||
static void
|
||||
ntb_send_link_down(struct ntb_transport_qp *qp)
|
||||
{
|
||||
|
@ -58,4 +58,5 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len);
|
||||
void ntb_transport_link_up(struct ntb_transport_qp *qp);
|
||||
void ntb_transport_link_down(struct ntb_transport_qp *qp);
|
||||
bool ntb_transport_link_query(struct ntb_transport_qp *qp);
|
||||
uint64_t ntb_transport_link_speed(struct ntb_transport_qp *qp);
|
||||
unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp);
|
||||
|
Loading…
Reference in New Issue
Block a user