All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH v5 net-next 05/15] nfp: allocate ring SW structs dynamically
Date: Thu,  7 Apr 2016 19:39:38 +0100	[thread overview]
Message-ID: <1460054388-471-6-git-send-email-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <1460054388-471-1-git-send-email-jakub.kicinski@netronome.com>

To be able to switch rings more easily on config changes
allocate them dynamically, separately from nfp_net structure.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net.h       |  6 ++---
 .../net/ethernet/netronome/nfp/nfp_net_common.c    | 28 +++++++++++++++++-----
 .../net/ethernet/netronome/nfp/nfp_net_debugfs.c   | 20 +++++++++-------
 3 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net.h b/drivers/net/ethernet/netronome/nfp/nfp_net.h
index 75683fb26734..fc005c982b7d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net.h
@@ -472,6 +472,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 +507,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];
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 7cd20fcd631a..66fab7162b7c 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -413,12 +413,6 @@ static void nfp_net_irqs_assign(struct net_device *netdev)
 		r_vec->irq_idx = NFP_NET_NON_Q_VECTORS + r;
 
 		cpumask_set_cpu(r, &r_vec->affinity_mask);
-
-		r_vec->tx_ring = &nn->tx_rings[r];
-		nfp_net_tx_ring_init(r_vec->tx_ring, r_vec, r);
-
-		r_vec->rx_ring = &nn->rx_rings[r];
-		nfp_net_rx_ring_init(r_vec->rx_ring, r_vec, r);
 	}
 }
 
@@ -1503,6 +1497,12 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
 	struct msix_entry *entry = &nn->irq_entries[r_vec->irq_idx];
 	int err;
 
+	r_vec->tx_ring = &nn->tx_rings[idx];
+	nfp_net_tx_ring_init(r_vec->tx_ring, r_vec, idx);
+
+	r_vec->rx_ring = &nn->rx_rings[idx];
+	nfp_net_rx_ring_init(r_vec->rx_ring, r_vec, idx);
+
 	snprintf(r_vec->name, sizeof(r_vec->name),
 		 "%s-rxtx-%d", nn->netdev->name, idx);
 	err = request_irq(entry->vector, r_vec->handler, 0, r_vec->name, r_vec);
@@ -1693,6 +1693,15 @@ static int nfp_net_netdev_open(struct net_device *netdev)
 		goto err_free_exn;
 	disable_irq(nn->irq_entries[NFP_NET_CFG_LSC].vector);
 
+	nn->rx_rings = kcalloc(nn->num_rx_rings, sizeof(*nn->rx_rings),
+			       GFP_KERNEL);
+	if (!nn->rx_rings)
+		goto err_free_lsc;
+	nn->tx_rings = kcalloc(nn->num_tx_rings, sizeof(*nn->tx_rings),
+			       GFP_KERNEL);
+	if (!nn->tx_rings)
+		goto err_free_rx_rings;
+
 	for (r = 0; r < nn->num_r_vecs; r++) {
 		err = nfp_net_prepare_vector(nn, &nn->r_vecs[r], r);
 		if (err)
@@ -1807,6 +1816,10 @@ err_free_tx_ring_p:
 err_cleanup_vec_p:
 		nfp_net_cleanup_vector(nn, &nn->r_vecs[r]);
 	}
+	kfree(nn->tx_rings);
+err_free_rx_rings:
+	kfree(nn->rx_rings);
+err_free_lsc:
 	nfp_net_aux_irq_free(nn, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 err_free_exn:
 	nfp_net_aux_irq_free(nn, NFP_NET_CFG_EXN, NFP_NET_IRQ_EXN_IDX);
@@ -1852,6 +1865,9 @@ static int nfp_net_netdev_close(struct net_device *netdev)
 		nfp_net_cleanup_vector(nn, &nn->r_vecs[r]);
 	}
 
+	kfree(nn->rx_rings);
+	kfree(nn->tx_rings);
+
 	nfp_net_aux_irq_free(nn, NFP_NET_CFG_LSC, NFP_NET_IRQ_LSC_IDX);
 	nfp_net_aux_irq_free(nn, NFP_NET_CFG_EXN, NFP_NET_IRQ_EXN_IDX);
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
index 4c97c713121c..f86a1f13d27b 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
@@ -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);
 	}
 }
 
-- 
1.9.1

  parent reply	other threads:[~2016-04-07 18:40 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 18:39 [PATCH v5 net-next 00/15] MTU/buffer reconfig changes Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 01/15] nfp: correct RX buffer length calculation Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 02/15] nfp: move link state interrupt request/free calls Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 03/15] nfp: break up nfp_net_{alloc|free}_rings Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 04/15] nfp: make *x_ring_init do all the init Jakub Kicinski
2016-04-07 18:39 ` Jakub Kicinski [this message]
2016-04-07 18:39 ` [PATCH v5 net-next 06/15] nfp: cleanup tx ring flush and rename to reset Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 07/15] nfp: reorganize initial filling of RX rings Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 08/15] nfp: preallocate RX buffers early in .ndo_open Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 09/15] nfp: move filling ring information to FW config Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 10/15] nfp: slice .ndo_open() and .ndo_stop() up Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 11/15] nfp: sync ring state during FW reconfiguration Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 12/15] nfp: propagate list buffer size in struct rx_ring Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 13/15] nfp: convert .ndo_change_mtu() to prepare/commit paradigm Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 14/15] nfp: pass ring count as function parameter Jakub Kicinski
2016-04-07 18:39 ` [PATCH v5 net-next 15/15] nfp: allow ring size reconfiguration at runtime Jakub Kicinski
2016-04-08 19:34 ` [PATCH v5 net-next 00/15] MTU/buffer reconfig changes David Miller
2016-04-08 19:34   ` [PATCH v5 net-next 00/15] MTU/buffer reconfig changes, [PATCH net-next v2 1/2] bpf, trace: add BPF_F_CURRENT_CPU flag for bpf_perf_event_output, [PATCH v2 1/5] mmc: tmio: give read32/write32 functions more descriptive names, Re: [patch net-next 0/5] mlxsw: small driver update, Re: [RFC PATCH 07/11] GENEVE: Add option to mangle IP IDs on inner headers when using TSO, Re: [PATCH/RFC v2] gpio: rcar: Add Runtime PM handling for interrupts, [v3,4/6] arm64: dts: salvator-x: enable PWM David Miller, Daniel Borkmann, Wolfram Sang, David Miller, Jesse Gross, Laurent Pinchart, Ulrich Hecht
  -- strict thread matches above, loose matches on Subject: below --
2016-04-26 16:53 [PATCH v2 0/5] mmc: tmio: make CTL_STATUS handling consistent Wolfram Sang
2016-04-26 16:53 ` [PATCH v2 1/5] mmc: tmio: give read32/write32 functions more descriptive names Wolfram Sang
2016-04-26 16:53 ` [PATCH v2 2/5] mmc: tmio: use BIT() within defines Wolfram Sang
2016-04-26 16:53 ` [PATCH v2 3/5] mmc: tmio: use CTL_STATUS consistently Wolfram Sang
2016-04-26 16:53 ` [PATCH v2 4/5] mmc: tmio/sdhi: distinguish between SCLKDIVEN and ILL_FUNC Wolfram Sang
2016-04-26 16:53 ` [PATCH v2 5/5] mmc: tmio: document CTL_STATUS handling Wolfram Sang
2016-04-27  8:31 ` [PATCH v2 0/5] mmc: tmio: make CTL_STATUS handling consistent Ulf Hansson
2016-04-18 19:01 [PATCH net-next v2 0/2] BPF updates Daniel Borkmann
2016-04-18 19:01 ` [PATCH net-next v2 1/2] bpf, trace: add BPF_F_CURRENT_CPU flag for bpf_perf_event_output Daniel Borkmann
2016-04-18 19:01 ` [PATCH net-next v2 2/2] bpf: add event output helper for notifications/sampling/logging Daniel Borkmann
2016-04-20  0:26 ` [PATCH net-next v2 0/2] BPF updates David Miller
2016-04-08 15:45 [patch net-next 0/5] mlxsw: small driver update Jiri Pirko
2016-04-08 15:45 ` [patch net-next 1/5] mlxsw: Move devlink port registration into common core code Jiri Pirko
2016-04-08 15:45 ` [patch net-next 2/5] mlxsw: Pass mlxsw_core as a param of mlxsw_core_skb_transmit* Jiri Pirko
2016-04-08 15:45 ` [patch net-next 3/5] mlxsw: Do not pass around driver_priv directly Jiri Pirko
2016-04-08 15:45 ` [patch net-next 4/5] mlxsw: reg: Share direction enum between SBPR, SBCM, SBPM Jiri Pirko
2016-04-08 15:45 ` [patch net-next 5/5] mlxsw: reg: Fix SBPM register name Jiri Pirko
2016-04-08 15:51 ` [patch net-next 0/5] mlxsw: small driver update Jiri Pirko
2016-04-08 17:07   ` David Miller
2016-04-08 17:11     ` Jiri Pirko
2016-04-07 22:31 [RFC PATCH 00/11] GSO partial and TSO FIXEDID support Alexander Duyck
2016-04-07 22:31 ` [RFC PATCH 01/11] GRE: Disable segmentation offloads w/ CSUM and we are encapsulated via FOU Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 02/11] ethtool: Add support for toggling any of the GSO offloads Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 03/11] GSO: Add GSO type for fixed IPv4 ID Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 04/11] GRO: Add support for TCP with fixed IPv4 ID field, limit tunnel IP ID values Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 05/11] GSO: Support partial segmentation offload Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 06/11] VXLAN: Add option to mangle IP IDs on inner headers when using TSO Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 07/11] GENEVE: " Alexander Duyck
2016-04-07 23:22   ` Jesse Gross
2016-04-07 23:52     ` Alexander Duyck
2016-04-08 21:40       ` Jesse Gross
2016-04-08 22:04         ` Alexander Duyck
2016-04-09 15:52           ` Jesse Gross
2016-04-09 17:36             ` Alexander Duyck
2016-04-09 18:02               ` Eric Dumazet
2016-04-09 18:32                 ` Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 08/11] Documentation: Add documentation for TSO and GSO features Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 09/11] i40e/i40evf: Add support for GSO partial with UDP_TUNNEL_CSUM and GRE_CSUM Alexander Duyck
2016-04-07 22:32 ` [RFC PATCH 10/11] ixgbe/ixgbevf: Add support for GSO partial Alexander Duyck
2016-04-07 22:33 ` [RFC PATCH 11/11] igb/igbvf: " Alexander Duyck
2016-03-31 11:39 [v3,6/6] clk: shmobile: r8a7795: add PWM clock Ulrich Hecht
2016-03-31 11:39 ` [PATCH v3 6/6] " Ulrich Hecht
2016-03-31 11:39 [v3,2/6] arm64: defconfig : add PWM driver support Ulrich Hecht
2016-03-31 11:39 ` [PATCH v3 2/6] " Ulrich Hecht
2016-03-31 11:39 [PATCH v3 0/6] R8A7795/Salvator-X PWM support Ulrich Hecht
2016-03-31 11:39 ` [PATCH v3 1/6] pwm: rcar: Use ARCH_RENESAS Ulrich Hecht
2016-04-06  1:18   ` [v3,1/6] " Simon Horman
2016-07-11  9:44   ` [PATCH v3 1/6] " Thierry Reding
2016-03-31 11:39 ` [PATCH v3 3/6] arm64: dts: r8a7795: Add PWM device nodes Ulrich Hecht
2016-03-31 11:39 ` [PATCH v3 4/6] arm64: dts: salvator-x: enable PWM Ulrich Hecht
2016-03-31 11:39 ` [PATCH v3 5/6] pwm: add R-Car H3 device tree bindings Ulrich Hecht
2016-04-06  1:23   ` [v3,5/6] " Simon Horman
2016-07-11  9:45   ` [PATCH v3 5/6] " Thierry Reding
2016-02-18 16:06 [PATCH/RFC v2] gpio: rcar: Add Runtime PM handling for interrupts Geert Uytterhoeven
2016-02-19  9:18 ` Linus Walleij
2016-02-19 11:59   ` Marc Zyngier
2016-04-11 16:26     ` Laurent Pinchart
2016-04-11 16:55       ` Marc Zyngier
2016-04-11 17:18         ` Geert Uytterhoeven
2016-04-12  8:06           ` Linus Walleij
2016-02-25  9:07 ` Linus Walleij
2016-02-25  9:37   ` Geert Uytterhoeven
2016-02-25 14:19     ` Linus Walleij
2016-02-25 14:26       ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460054388-471-6-git-send-email-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.