All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghu Vatsavayi <rvatsavayi@caviumnetworks.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>,
	Raghu Vatsavayi <rvatsavayi@caviumnetworks.com>,
	Derek Chickles <derek.chickles@caviumnetworks.com>,
	Satanand Burla <satananda.burla@caviumnetworks.com>,
	Felix Manlunas <felix.manlunas@caviumnetworks.com>,
	Raghu Vatsavayi <raghu.vatsavayi@caviumnetworks.com>
Subject: [PATCH net-next V2 13/18] liquidio: CN23XX IQ access
Date: Fri, 12 Aug 2016 11:20:30 -0700	[thread overview]
Message-ID: <1471026035-15323-14-git-send-email-rvatsavayi@caviumnetworks.com> (raw)
In-Reply-To: <1471026035-15323-1-git-send-email-rvatsavayi@caviumnetworks.com>

Adds support for Instruction Queue(IQ) index manipulation
routines through bar1 of cn23xx.

Signed-off-by: Derek Chickles <derek.chickles@caviumnetworks.com>
Signed-off-by: Satanand Burla <satananda.burla@caviumnetworks.com>
Signed-off-by: Felix Manlunas <felix.manlunas@caviumnetworks.com>
Signed-off-by: Raghu Vatsavayi <raghu.vatsavayi@caviumnetworks.com>
---
 .../ethernet/cavium/liquidio/cn23xx_pf_device.c    | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
index f1d4572..e110e5a 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_device.c
@@ -908,6 +908,67 @@ static void cn23xx_reinit_regs(struct octeon_device *oct)
 	}
 }
 
+static void cn23xx_bar1_idx_setup(struct octeon_device *oct, u64 core_addr,
+				  u32 idx, int valid)
+{
+	u64 bar1;
+	u64 reg_adr;
+
+	if (!valid) {
+		reg_adr = lio_pci_readq(
+			oct, CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+		WRITE_ONCE(bar1, reg_adr);
+		lio_pci_writeq(oct, (READ_ONCE(bar1) & 0xFFFFFFFEULL),
+			       CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+		reg_adr = lio_pci_readq(
+			oct, CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+		WRITE_ONCE(bar1, reg_adr);
+		return;
+	}
+
+	/*  The PEM(0..3)_BAR1_INDEX(0..15)[ADDR_IDX]<23:4> stores
+	 *  bits <41:22> of the Core Addr
+	 */
+	lio_pci_writeq(oct, (((core_addr >> 22) << 4) | PCI_BAR1_MASK),
+		       CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+
+	WRITE_ONCE(bar1, lio_pci_readq(
+		   oct, CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx)));
+}
+
+static void cn23xx_bar1_idx_write(struct octeon_device *oct, u32 idx, u32 mask)
+{
+	lio_pci_writeq(oct, mask,
+		       CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+}
+
+static u32 cn23xx_bar1_idx_read(struct octeon_device *oct, u32 idx)
+{
+	return (u32)lio_pci_readq(
+	    oct, CN23XX_PEM_BAR1_INDEX_REG(oct->pcie_port, idx));
+}
+
+/* always call with lock held */
+static u32 cn23xx_update_read_index(struct octeon_instr_queue *iq)
+{
+	u32 new_idx;
+	u32 last_done;
+	u32 pkt_in_done = readl(iq->inst_cnt_reg);
+
+	last_done = pkt_in_done - iq->pkt_in_done;
+	iq->pkt_in_done = pkt_in_done;
+
+	/* Modulo of the new index with the IQ size will give us
+	 * the new index.  The iq->reset_instr_cnt is always zero for
+	 * cn23xx, so no extra adjustments are needed.
+	 */
+	new_idx = (iq->octeon_read_index +
+		   (u32)(last_done & CN23XX_PKT_IN_DONE_CNT_MASK)) %
+		  iq->max_count;
+
+	return new_idx;
+}
+
 static void cn23xx_enable_pf_interrupt(struct octeon_device *oct, u8 intr_flag)
 {
 	struct octeon_cn23xx_pf *cn23xx = (struct octeon_cn23xx_pf *)oct->chip;
@@ -1085,6 +1146,11 @@ int setup_cn23xx_octeon_pf_device(struct octeon_device *oct)
 	oct->fn_list.soft_reset = cn23xx_pf_soft_reset;
 	oct->fn_list.setup_device_regs = cn23xx_setup_pf_device_regs;
 	oct->fn_list.reinit_regs = cn23xx_reinit_regs;
+	oct->fn_list.update_iq_read_idx = cn23xx_update_read_index;
+
+	oct->fn_list.bar1_idx_setup = cn23xx_bar1_idx_setup;
+	oct->fn_list.bar1_idx_write = cn23xx_bar1_idx_write;
+	oct->fn_list.bar1_idx_read = cn23xx_bar1_idx_read;
 
 	oct->fn_list.enable_interrupt = cn23xx_enable_pf_interrupt;
 	oct->fn_list.disable_interrupt = cn23xx_disable_pf_interrupt;
-- 
1.8.3.1

  parent reply	other threads:[~2016-08-12 18:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 18:20 [PATCH net-next V2 00/18] liquidio CN23XX support Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 01/18] liquidio: Consolidate common functionality Raghu Vatsavayi
2016-08-12 19:21   ` Joe Perches
2016-08-12 18:20 ` [PATCH net-next V2 02/18] liquidio: Firmware version management Raghu Vatsavayi
2016-08-12 19:24   ` Joe Perches
2016-08-12 18:20 ` [PATCH net-next V2 03/18] liquidio: Common enable irq function Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 04/18] liquidio: CN23XX register definitions Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 05/18] liquidio: CN23XX queue definitions Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 06/18] liquidio: CN23XX device init and sriov config Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 07/18] liquidio: CN23XX register setup Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 08/18] liquidio: CN23XX queue manipulation Raghu Vatsavayi
2016-08-12 19:30   ` Joe Perches
2016-08-12 18:20 ` [PATCH net-next V2 09/18] liquidio: MSIX support for CN23XX Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 10/18] liquidio: CN23XX firmware download Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 11/18] liquidio: link and control commands Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 12/18] liquidio: RX " Raghu Vatsavayi
2016-08-12 18:20 ` Raghu Vatsavayi [this message]
2016-08-12 18:20 ` [PATCH net-next V2 14/18] liquidio: CN23XX octeon3 instruction Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 15/18] liquidio: ethtool and led control support Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 16/18] liquidio: CN23XX health monitoring Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 17/18] liquidio: CN23XX napi support Raghu Vatsavayi
2016-08-12 18:20 ` [PATCH net-next V2 18/18] liquidio:CN23XX pause frame support Raghu Vatsavayi
2016-08-13 18:59 ` [PATCH net-next V2 00/18] liquidio CN23XX support David Miller

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=1471026035-15323-14-git-send-email-rvatsavayi@caviumnetworks.com \
    --to=rvatsavayi@caviumnetworks.com \
    --cc=davem@davemloft.net \
    --cc=derek.chickles@caviumnetworks.com \
    --cc=felix.manlunas@caviumnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=raghu.vatsavayi@caviumnetworks.com \
    --cc=satananda.burla@caviumnetworks.com \
    /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.