net: tsec: Move rx_idx and tx_idx to struct tsec_private
At present rx_idx and tx_idx are declared as static variables in the driver codes. To support multiple interfaces, move it to struct tsec_private. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
9872b736f9
commit
362b123f47
@ -23,9 +23,6 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
|
|
||||||
#define TX_BUF_CNT 2
|
#define TX_BUF_CNT 2
|
||||||
|
|
||||||
static uint rx_idx; /* index of the current RX buffer */
|
|
||||||
static uint tx_idx; /* index of the current TX buffer */
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
static struct txbd8 __iomem txbd[TX_BUF_CNT] __aligned(8);
|
static struct txbd8 __iomem txbd[TX_BUF_CNT] __aligned(8);
|
||||||
static struct rxbd8 __iomem rxbd[PKTBUFSRX] __aligned(8);
|
static struct rxbd8 __iomem rxbd[PKTBUFSRX] __aligned(8);
|
||||||
@ -280,22 +277,23 @@ void redundant_init(struct eth_device *dev)
|
|||||||
tsec_send(dev, (void *)pkt, sizeof(pkt));
|
tsec_send(dev, (void *)pkt, sizeof(pkt));
|
||||||
|
|
||||||
/* Wait for buffer to be received */
|
/* Wait for buffer to be received */
|
||||||
for (t = 0; in_be16(&rxbd[rx_idx].status) & RXBD_EMPTY; t++) {
|
for (t = 0; in_be16(&rxbd[priv->rx_idx].status) & RXBD_EMPTY;
|
||||||
|
t++) {
|
||||||
if (t >= 10 * TOUT_LOOP) {
|
if (t >= 10 * TOUT_LOOP) {
|
||||||
printf("%s: tsec: rx error\n", dev->name);
|
printf("%s: tsec: rx error\n", dev->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!memcmp(pkt, (void *)net_rx_packets[rx_idx], sizeof(pkt)))
|
if (!memcmp(pkt, net_rx_packets[priv->rx_idx], sizeof(pkt)))
|
||||||
fail = 0;
|
fail = 0;
|
||||||
|
|
||||||
out_be16(&rxbd[rx_idx].length, 0);
|
out_be16(&rxbd[priv->rx_idx].length, 0);
|
||||||
status = RXBD_EMPTY;
|
status = RXBD_EMPTY;
|
||||||
if ((rx_idx + 1) == PKTBUFSRX)
|
if ((priv->rx_idx + 1) == PKTBUFSRX)
|
||||||
status |= RXBD_WRAP;
|
status |= RXBD_WRAP;
|
||||||
out_be16(&rxbd[rx_idx].status, status);
|
out_be16(&rxbd[priv->rx_idx].status, status);
|
||||||
rx_idx = (rx_idx + 1) % PKTBUFSRX;
|
priv->rx_idx = (priv->rx_idx + 1) % PKTBUFSRX;
|
||||||
|
|
||||||
if (in_be32(®s->ievent) & IEVENT_BSY) {
|
if (in_be32(®s->ievent) & IEVENT_BSY) {
|
||||||
out_be32(®s->ievent, IEVENT_BSY);
|
out_be32(®s->ievent, IEVENT_BSY);
|
||||||
@ -330,8 +328,8 @@ static void startup_tsec(struct eth_device *dev)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* reset the indices to zero */
|
/* reset the indices to zero */
|
||||||
rx_idx = 0;
|
priv->rx_idx = 0;
|
||||||
tx_idx = 0;
|
priv->tx_idx = 0;
|
||||||
#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
|
#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
|
||||||
uint svr;
|
uint svr;
|
||||||
#endif
|
#endif
|
||||||
@ -388,32 +386,32 @@ static int tsec_send(struct eth_device *dev, void *packet, int length)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Find an empty buffer descriptor */
|
/* Find an empty buffer descriptor */
|
||||||
for (i = 0; in_be16(&txbd[tx_idx].status) & TXBD_READY; i++) {
|
for (i = 0; in_be16(&txbd[priv->tx_idx].status) & TXBD_READY; i++) {
|
||||||
if (i >= TOUT_LOOP) {
|
if (i >= TOUT_LOOP) {
|
||||||
debug("%s: tsec: tx buffers full\n", dev->name);
|
debug("%s: tsec: tx buffers full\n", dev->name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out_be32(&txbd[tx_idx].bufptr, (u32)packet);
|
out_be32(&txbd[priv->tx_idx].bufptr, (u32)packet);
|
||||||
out_be16(&txbd[tx_idx].length, length);
|
out_be16(&txbd[priv->tx_idx].length, length);
|
||||||
status = in_be16(&txbd[tx_idx].status);
|
status = in_be16(&txbd[priv->tx_idx].status);
|
||||||
out_be16(&txbd[tx_idx].status, status |
|
out_be16(&txbd[priv->tx_idx].status, status |
|
||||||
(TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT));
|
(TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT));
|
||||||
|
|
||||||
/* Tell the DMA to go */
|
/* Tell the DMA to go */
|
||||||
out_be32(®s->tstat, TSTAT_CLEAR_THALT);
|
out_be32(®s->tstat, TSTAT_CLEAR_THALT);
|
||||||
|
|
||||||
/* Wait for buffer to be transmitted */
|
/* Wait for buffer to be transmitted */
|
||||||
for (i = 0; in_be16(&txbd[tx_idx].status) & TXBD_READY; i++) {
|
for (i = 0; in_be16(&txbd[priv->tx_idx].status) & TXBD_READY; i++) {
|
||||||
if (i >= TOUT_LOOP) {
|
if (i >= TOUT_LOOP) {
|
||||||
debug("%s: tsec: tx error\n", dev->name);
|
debug("%s: tsec: tx error\n", dev->name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tx_idx = (tx_idx + 1) % TX_BUF_CNT;
|
priv->tx_idx = (priv->tx_idx + 1) % TX_BUF_CNT;
|
||||||
result = in_be16(&txbd[tx_idx].status) & TXBD_STATS;
|
result = in_be16(&txbd[priv->tx_idx].status) & TXBD_STATS;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -423,26 +421,26 @@ static int tsec_recv(struct eth_device *dev)
|
|||||||
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
struct tsec_private *priv = (struct tsec_private *)dev->priv;
|
||||||
struct tsec __iomem *regs = priv->regs;
|
struct tsec __iomem *regs = priv->regs;
|
||||||
|
|
||||||
while (!(in_be16(&rxbd[rx_idx].status) & RXBD_EMPTY)) {
|
while (!(in_be16(&rxbd[priv->rx_idx].status) & RXBD_EMPTY)) {
|
||||||
int length = in_be16(&rxbd[rx_idx].length);
|
int length = in_be16(&rxbd[priv->rx_idx].length);
|
||||||
uint16_t status = in_be16(&rxbd[rx_idx].status);
|
uint16_t status = in_be16(&rxbd[priv->rx_idx].status);
|
||||||
|
uchar *packet = net_rx_packets[priv->rx_idx];
|
||||||
|
|
||||||
/* Send the packet up if there were no errors */
|
/* Send the packet up if there were no errors */
|
||||||
if (!(status & RXBD_STATS))
|
if (!(status & RXBD_STATS))
|
||||||
net_process_received_packet(net_rx_packets[rx_idx],
|
net_process_received_packet(packet, length - 4);
|
||||||
length - 4);
|
|
||||||
else
|
else
|
||||||
printf("Got error %x\n", (status & RXBD_STATS));
|
printf("Got error %x\n", (status & RXBD_STATS));
|
||||||
|
|
||||||
out_be16(&rxbd[rx_idx].length, 0);
|
out_be16(&rxbd[priv->rx_idx].length, 0);
|
||||||
|
|
||||||
status = RXBD_EMPTY;
|
status = RXBD_EMPTY;
|
||||||
/* Set the wrap bit if this is the last element in the list */
|
/* Set the wrap bit if this is the last element in the list */
|
||||||
if ((rx_idx + 1) == PKTBUFSRX)
|
if ((priv->rx_idx + 1) == PKTBUFSRX)
|
||||||
status |= RXBD_WRAP;
|
status |= RXBD_WRAP;
|
||||||
out_be16(&rxbd[rx_idx].status, status);
|
out_be16(&rxbd[priv->rx_idx].status, status);
|
||||||
|
|
||||||
rx_idx = (rx_idx + 1) % PKTBUFSRX;
|
priv->rx_idx = (priv->rx_idx + 1) % PKTBUFSRX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_be32(®s->ievent) & IEVENT_BSY) {
|
if (in_be32(®s->ievent) & IEVENT_BSY) {
|
||||||
|
@ -396,6 +396,8 @@ struct tsec_private {
|
|||||||
uint phyaddr;
|
uint phyaddr;
|
||||||
char mii_devname[16];
|
char mii_devname[16];
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
uint rx_idx; /* index of the current RX buffer */
|
||||||
|
uint tx_idx; /* index of the current TX buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tsec_info_struct {
|
struct tsec_info_struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user