Commit 67d2ee25 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: octeon-ethernet: rgmii: refactor gmx block interrupt handling

Code for gmx0 and gmx1 block is identical, move it into a function.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8d2e817
...@@ -183,104 +183,63 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) ...@@ -183,104 +183,63 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
} }
} }
static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id) static int cmv_oct_rgmii_gmx_interrupt(int interface)
{ {
union cvmx_npi_rsl_int_blocks rsl_int_blocks;
int index; int index;
irqreturn_t return_status = IRQ_NONE; int count = 0;
rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS); /* Loop through every port of this interface */
for (index = 0;
/* Check and see if this interrupt was caused by the GMX0 block */ index < cvmx_helper_ports_on_interface(interface);
if (rsl_int_blocks.s.gmx0) { index++) {
union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
int interface = 0; /* Read the GMX interrupt status bits */
/* Loop through every port of this interface */ gmx_rx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
for (index = 0;
index < cvmx_helper_ports_on_interface(interface);
index++) {
/* Read the GMX interrupt status bits */
union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
gmx_rx_int_reg.u64 =
cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
(index, interface)); (index, interface));
gmx_rx_int_reg.u64 &= gmx_rx_int_reg.u64 &= cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
(index, interface)); (index, interface));
/* Poll the port if inband status changed */
if (gmx_rx_int_reg.s.phy_dupx
|| gmx_rx_int_reg.s.phy_link
|| gmx_rx_int_reg.s.phy_spd) {
struct net_device *dev = /* Poll the port if inband status changed */
if (gmx_rx_int_reg.s.phy_dupx || gmx_rx_int_reg.s.phy_link ||
gmx_rx_int_reg.s.phy_spd) {
struct net_device *dev =
cvm_oct_device[cvmx_helper_get_ipd_port cvm_oct_device[cvmx_helper_get_ipd_port
(interface, index)]; (interface, index)];
struct octeon_ethernet *priv = netdev_priv(dev); struct octeon_ethernet *priv = netdev_priv(dev);
if (dev && if (dev && !atomic_read(&cvm_oct_poll_queue_stopping))
!atomic_read(&cvm_oct_poll_queue_stopping)) queue_work(cvm_oct_poll_queue,
queue_work(cvm_oct_poll_queue, &priv->port_work);
&priv->port_work);
gmx_rx_int_reg.u64 = 0;
gmx_rx_int_reg.u64 = 0; gmx_rx_int_reg.s.phy_dupx = 1;
gmx_rx_int_reg.s.phy_dupx = 1; gmx_rx_int_reg.s.phy_link = 1;
gmx_rx_int_reg.s.phy_link = 1; gmx_rx_int_reg.s.phy_spd = 1;
gmx_rx_int_reg.s.phy_spd = 1; cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface),
cvmx_write_csr(CVMX_GMXX_RXX_INT_REG gmx_rx_int_reg.u64);
(index, interface), count++;
gmx_rx_int_reg.u64);
return_status = IRQ_HANDLED;
}
} }
} }
return count;
}
/* Check and see if this interrupt was caused by the GMX1 block */ static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id)
if (rsl_int_blocks.s.gmx1) { {
union cvmx_npi_rsl_int_blocks rsl_int_blocks;
int interface = 1; int count = 0;
/* Loop through every port of this interface */
for (index = 0;
index < cvmx_helper_ports_on_interface(interface);
index++) {
/* Read the GMX interrupt status bits */
union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
gmx_rx_int_reg.u64 = rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS);
cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
(index, interface));
gmx_rx_int_reg.u64 &=
cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
(index, interface));
/* Poll the port if inband status changed */
if (gmx_rx_int_reg.s.phy_dupx
|| gmx_rx_int_reg.s.phy_link
|| gmx_rx_int_reg.s.phy_spd) {
struct net_device *dev = /* Check and see if this interrupt was caused by the GMX0 block */
cvm_oct_device[cvmx_helper_get_ipd_port if (rsl_int_blocks.s.gmx0)
(interface, index)]; count += cmv_oct_rgmii_gmx_interrupt(0);
struct octeon_ethernet *priv = netdev_priv(dev);
if (dev && /* Check and see if this interrupt was caused by the GMX1 block */
!atomic_read(&cvm_oct_poll_queue_stopping)) if (rsl_int_blocks.s.gmx1)
queue_work(cvm_oct_poll_queue, count += cmv_oct_rgmii_gmx_interrupt(1);
&priv->port_work);
gmx_rx_int_reg.u64 = 0; return count ? IRQ_HANDLED : IRQ_NONE;
gmx_rx_int_reg.s.phy_dupx = 1;
gmx_rx_int_reg.s.phy_link = 1;
gmx_rx_int_reg.s.phy_spd = 1;
cvmx_write_csr(CVMX_GMXX_RXX_INT_REG
(index, interface),
gmx_rx_int_reg.u64);
return_status = IRQ_HANDLED;
}
}
}
return return_status;
} }
int cvm_oct_rgmii_open(struct net_device *dev) int cvm_oct_rgmii_open(struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment