Skip to content

Commit b590c76

Browse files
committed
handle multiple queues when tearing down/re-creating vmbus channels to change mtu
1 parent 5f2675d commit b590c76

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

drivers/net/netvsc/hn_ethdev.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,12 +1102,13 @@ static int
11021102
hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
11031103
{
11041104
struct hn_data *hv = dev->data->dev_private;
1105-
struct hn_rx_queue *rxq = dev->data->rx_queues[0];
1106-
struct hn_tx_queue *txq = dev->data->tx_queues[0];
1105+
struct hn_rx_queue **rxqs = (struct hn_rx_queue **)dev->data->rx_queues;
1106+
struct hn_tx_queue **txqs = (struct hn_tx_queue **)dev->data->tx_queues;
11071107
struct rte_eth_dev *vf_dev;
11081108
unsigned int orig_mtu = dev->data->mtu;
11091109
uint32_t rndis_mtu;
11101110
int ret = 0;
1111+
int i;
11111112

11121113
if (dev->data->dev_started) {
11131114
PMD_DRV_LOG(ERR, "Device must be stopped before changing MTU");
@@ -1128,7 +1129,6 @@ hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
11281129

11291130
/* Release channel resources */
11301131
hn_detach(hv);
1131-
hn_chim_uninit(dev);
11321132

11331133
/* Close primary channel */
11341134
rte_vmbus_chan_close(hv->channels[0]);
@@ -1142,7 +1142,7 @@ hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
11421142
return ret;
11431143
}
11441144

1145-
/* Update pointers to re-mapped memory */
1145+
/* Update pointers to re-mapped UIO resources */
11461146
hv->rxbuf_res = hv->vmbus->resource[HV_RECV_BUF_MAP];
11471147
hv->chim_res = hv->vmbus->resource[HV_SEND_BUF_MAP];
11481148

@@ -1155,23 +1155,37 @@ hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
11551155

11561156
rte_vmbus_set_latency(hv->vmbus, hv->channels[0], hv->latency);
11571157

1158-
rxq->chan = hv->channels[0];
1159-
txq->chan = hv->channels[0];
1158+
/* Point primary queues at new primary channel */
1159+
rxqs[0]->chan = hv->channels[0];
1160+
txqs[0]->chan = hv->channels[0];
11601161

11611162
ret = hn_attach(hv, mtu);
11621163
if (ret)
11631164
goto error;
11641165

1165-
ret = hn_chim_init(dev);
1166+
/* Create vmbus subchannels, additional RNDIS configuration */
1167+
ret = hn_dev_configure(dev);
11661168
if (ret)
11671169
goto error;
1170+
1171+
/* Point any additional queues at new subchannels */
1172+
for (i = 1; i < dev->data->nb_rx_queues; i++)
1173+
rxqs[i]->chan = hv->channels[i];
1174+
for (i = 1; i < dev->data->nb_tx_queues; i++)
1175+
txqs[i]->chan = hv->channels[i];
11681176

1169-
ret = hn_dev_configure(dev);
1170-
if (!ret)
1171-
goto out;
1177+
out:
1178+
if (hn_rndis_get_mtu(hv, &rndis_mtu))
1179+
PMD_DRV_LOG(ERR, "Could not get MTU via RNDIS");
1180+
else {
1181+
dev->data->mtu = (uint16_t)rndis_mtu;
1182+
PMD_DRV_LOG(DEBUG, "RNDIS MTU is %u", dev->data->mtu);
1183+
}
1184+
1185+
return ret;
11721186

11731187
error:
1174-
/* In case of error, attempt rollback to original MTU */
1188+
/* In case of error, attempt to restore original MTU */
11751189
if (hn_attach(hv, orig_mtu))
11761190
PMD_DRV_LOG(ERR, "Restoring original MTU failed");
11771191

@@ -1181,14 +1195,6 @@ hn_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
11811195
vf_dev->dev_ops->mtu_set(vf_dev, orig_mtu);
11821196
rte_rwlock_read_unlock(&hv->vf_lock);
11831197

1184-
out:
1185-
if (hn_rndis_get_mtu(hv, &rndis_mtu))
1186-
PMD_DRV_LOG(ERR, "Could not get MTU via RNDIS");
1187-
else {
1188-
dev->data->mtu = (uint16_t)rndis_mtu;
1189-
PMD_DRV_LOG(DEBUG, "RNDIS MTU is %u", dev->data->mtu);
1190-
}
1191-
11921198
return ret;
11931199
}
11941200

0 commit comments

Comments
 (0)