Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24d390b2 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'nfp-mtu-buffer-reconfig'



Jakub Kicinski says:

====================
MTU/buffer reconfig changes

I re-discussed MPLS/MTU internally, dropped it from the patch 1,
re-tested everything, found out I forgot about debugfs pointers,
fixed that as well.

v5:
 - don't reserve space in RX buffers for MPLS label stack
   (patch 1);
 - fix debugfs pointers to ring structures (patch 5).
v4:
 - cut down on unrelated patches;
 - don't "close" the device on error path.

--- v4 cover letter

Previous series included some not entirely related patches,
this one is cut down.  Main issue I'm trying to solve here
is that .ndo_change_mtu() in nfpvf driver is doing full
close/open to reallocate buffers - which if open fails
can result in device being basically closed even though
the interface is started.  As suggested by you I try to move
towards a paradigm where the resources are allocated first
and the MTU change is only done once I'm certain (almost)
nothing can fail.  Almost because I need to communicate
with FW and that can always time out.

Patch 1 fixes small issue.  Next 10 patches reorganize things
so that I can easily allocate new rings and sets of buffers
while the device is running.  Patches 13 and 15 reshape the
.ndo_change_mtu() and ethtool's ring-resize operation into
desired form.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 70f767d3 cc7c0333
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -298,6 +298,8 @@ struct nfp_net_rx_buf {
 * @rxds:       Virtual address of FL/RX ring in host memory
 * @dma:        DMA address of the FL/RX ring
 * @size:       Size, in bytes, of the FL/RX ring (needed to free)
 * @bufsz:	Buffer allocation size for convenience of management routines
 *		(NOTE: this is in second cache line, do not use on fast path!)
 */
struct nfp_net_rx_ring {
	struct nfp_net_r_vector *r_vec;
@@ -319,6 +321,7 @@ struct nfp_net_rx_ring {

	dma_addr_t dma;
	unsigned int size;
	unsigned int bufsz;
} ____cacheline_aligned;

/**
@@ -472,6 +475,9 @@ struct nfp_net {

	u32 rx_offset;

	struct nfp_net_tx_ring *tx_rings;
	struct nfp_net_rx_ring *rx_rings;

#ifdef CONFIG_PCI_IOV
	unsigned int num_vfs;
	struct vf_data_storage *vfinfo;
@@ -504,9 +510,6 @@ struct nfp_net {
	int txd_cnt;
	int rxd_cnt;

	struct nfp_net_tx_ring tx_rings[NFP_NET_MAX_TX_RINGS];
	struct nfp_net_rx_ring rx_rings[NFP_NET_MAX_RX_RINGS];

	u8 num_irqs;
	u8 num_r_vecs;
	struct nfp_net_r_vector r_vecs[NFP_NET_MAX_TX_RINGS];
@@ -721,6 +724,7 @@ void nfp_net_rss_write_key(struct nfp_net *nn);
void nfp_net_coalesce_write_cfg(struct nfp_net *nn);
int nfp_net_irqs_alloc(struct nfp_net *nn);
void nfp_net_irqs_disable(struct nfp_net *nn);
int nfp_net_set_ring_size(struct nfp_net *nn, u32 rxd_cnt, u32 txd_cnt);

#ifdef CONFIG_NFP_NET_DEBUG
void nfp_net_debugfs_create(void);
+599 −304

File changed.

Preview size limit exceeded, changes collapsed.

+12 −8
Original line number Diff line number Diff line
@@ -40,8 +40,9 @@ static struct dentry *nfp_dir;

static int nfp_net_debugfs_rx_q_read(struct seq_file *file, void *data)
{
	struct nfp_net_rx_ring *rx_ring = file->private;
	int fl_rd_p, fl_wr_p, rx_rd_p, rx_wr_p, rxd_cnt;
	struct nfp_net_r_vector *r_vec = file->private;
	struct nfp_net_rx_ring *rx_ring;
	struct nfp_net_rx_desc *rxd;
	struct sk_buff *skb;
	struct nfp_net *nn;
@@ -49,9 +50,10 @@ static int nfp_net_debugfs_rx_q_read(struct seq_file *file, void *data)

	rtnl_lock();

	if (!rx_ring->r_vec || !rx_ring->r_vec->nfp_net)
	if (!r_vec->nfp_net || !r_vec->rx_ring)
		goto out;
	nn = rx_ring->r_vec->nfp_net;
	nn = r_vec->nfp_net;
	rx_ring = r_vec->rx_ring;
	if (!netif_running(nn->netdev))
		goto out;

@@ -115,7 +117,8 @@ static const struct file_operations nfp_rx_q_fops = {

static int nfp_net_debugfs_tx_q_read(struct seq_file *file, void *data)
{
	struct nfp_net_tx_ring *tx_ring = file->private;
	struct nfp_net_r_vector *r_vec = file->private;
	struct nfp_net_tx_ring *tx_ring;
	struct nfp_net_tx_desc *txd;
	int d_rd_p, d_wr_p, txd_cnt;
	struct sk_buff *skb;
@@ -124,9 +127,10 @@ static int nfp_net_debugfs_tx_q_read(struct seq_file *file, void *data)

	rtnl_lock();

	if (!tx_ring->r_vec || !tx_ring->r_vec->nfp_net)
	if (!r_vec->nfp_net || !r_vec->tx_ring)
		goto out;
	nn = tx_ring->r_vec->nfp_net;
	nn = r_vec->nfp_net;
	tx_ring = r_vec->tx_ring;
	if (!netif_running(nn->netdev))
		goto out;

@@ -207,13 +211,13 @@ void nfp_net_debugfs_adapter_add(struct nfp_net *nn)
	for (i = 0; i < nn->num_rx_rings; i++) {
		sprintf(int_name, "%d", i);
		debugfs_create_file(int_name, S_IRUSR, rx,
				    &nn->rx_rings[i], &nfp_rx_q_fops);
				    &nn->r_vecs[i], &nfp_rx_q_fops);
	}

	for (i = 0; i < nn->num_tx_rings; i++) {
		sprintf(int_name, "%d", i);
		debugfs_create_file(int_name, S_IRUSR, tx,
				    &nn->tx_rings[i], &nfp_tx_q_fops);
				    &nn->r_vecs[i], &nfp_tx_q_fops);
	}
}

+9 −21
Original line number Diff line number Diff line
@@ -153,37 +153,25 @@ static int nfp_net_set_ringparam(struct net_device *netdev,
	struct nfp_net *nn = netdev_priv(netdev);
	u32 rxd_cnt, txd_cnt;

	if (netif_running(netdev)) {
		/* Some NIC drivers allow reconfiguration on the fly,
		 * some down the interface, change and then up it
		 * again.  For now we don't allow changes when the
		 * device is up.
		 */
		nn_warn(nn, "Can't change rings while device is up\n");
		return -EBUSY;
	}

	/* We don't have separate queues/rings for small/large frames. */
	if (ring->rx_mini_pending || ring->rx_jumbo_pending)
		return -EINVAL;

	/* Round up to supported values */
	rxd_cnt = roundup_pow_of_two(ring->rx_pending);
	rxd_cnt = max_t(u32, rxd_cnt, NFP_NET_MIN_RX_DESCS);
	rxd_cnt = min_t(u32, rxd_cnt, NFP_NET_MAX_RX_DESCS);

	txd_cnt = roundup_pow_of_two(ring->tx_pending);
	txd_cnt = max_t(u32, txd_cnt, NFP_NET_MIN_TX_DESCS);
	txd_cnt = min_t(u32, txd_cnt, NFP_NET_MAX_TX_DESCS);

	if (nn->rxd_cnt != rxd_cnt || nn->txd_cnt != txd_cnt)
	if (rxd_cnt < NFP_NET_MIN_RX_DESCS || rxd_cnt > NFP_NET_MAX_RX_DESCS ||
	    txd_cnt < NFP_NET_MIN_TX_DESCS || txd_cnt > NFP_NET_MAX_TX_DESCS)
		return -EINVAL;

	if (nn->rxd_cnt == rxd_cnt && nn->txd_cnt == txd_cnt)
		return 0;

	nn_dbg(nn, "Change ring size: RxQ %u->%u, TxQ %u->%u\n",
	       nn->rxd_cnt, rxd_cnt, nn->txd_cnt, txd_cnt);

	nn->rxd_cnt = rxd_cnt;
	nn->txd_cnt = txd_cnt;

	return 0;
	return nfp_net_set_ring_size(nn, rxd_cnt, txd_cnt);
}

static void nfp_net_get_strings(struct net_device *netdev,