net: lan966x: use a few FDMA helpers throughout
The library provides helpers for a number of DCB and DB operations. Use these throughout the code and remove the old ones. Signed-off-by: Daniel Machon <daniel.machon@microchip.com> Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
c06fef96c7
commit
9fbc5719f6
|
@ -126,14 +126,6 @@ static int lan966x_fdma_rx_alloc(struct lan966x_rx *rx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lan966x_fdma_rx_advance_dcb(struct lan966x_rx *rx)
|
|
||||||
{
|
|
||||||
struct fdma *fdma = &rx->fdma;
|
|
||||||
|
|
||||||
fdma->dcb_index++;
|
|
||||||
fdma->dcb_index &= fdma->n_dcbs - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lan966x_fdma_rx_start(struct lan966x_rx *rx)
|
static void lan966x_fdma_rx_start(struct lan966x_rx *rx)
|
||||||
{
|
{
|
||||||
struct lan966x *lan966x = rx->lan966x;
|
struct lan966x *lan966x = rx->lan966x;
|
||||||
|
@ -355,8 +347,8 @@ static void lan966x_fdma_tx_clear_buf(struct lan966x *lan966x, int weight)
|
||||||
if (!dcb_buf->used)
|
if (!dcb_buf->used)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
db = &fdma->dcbs[i].db[0];
|
db = fdma_db_get(fdma, i, 0);
|
||||||
if (!(db->status & FDMA_DCB_STATUS_DONE))
|
if (!fdma_db_is_done(db))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dcb_buf->dev->stats.tx_packets++;
|
dcb_buf->dev->stats.tx_packets++;
|
||||||
|
@ -396,19 +388,6 @@ static void lan966x_fdma_tx_clear_buf(struct lan966x *lan966x, int weight)
|
||||||
spin_unlock_irqrestore(&lan966x->tx_lock, flags);
|
spin_unlock_irqrestore(&lan966x->tx_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lan966x_fdma_rx_more_frames(struct lan966x_rx *rx)
|
|
||||||
{
|
|
||||||
struct fdma *fdma = &rx->fdma;
|
|
||||||
struct fdma_db *db;
|
|
||||||
|
|
||||||
/* Check if there is any data */
|
|
||||||
db = &fdma->dcbs[fdma->dcb_index].db[fdma->db_index];
|
|
||||||
if (unlikely(!(db->status & FDMA_DCB_STATUS_DONE)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port)
|
static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port)
|
||||||
{
|
{
|
||||||
struct lan966x *lan966x = rx->lan966x;
|
struct lan966x *lan966x = rx->lan966x;
|
||||||
|
@ -417,7 +396,7 @@ static int lan966x_fdma_rx_check_frame(struct lan966x_rx *rx, u64 *src_port)
|
||||||
struct fdma_db *db;
|
struct fdma_db *db;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
|
||||||
db = &fdma->dcbs[fdma->dcb_index].db[fdma->db_index];
|
db = fdma_db_next_get(fdma);
|
||||||
page = rx->page[fdma->dcb_index][fdma->db_index];
|
page = rx->page[fdma->dcb_index][fdma->db_index];
|
||||||
if (unlikely(!page))
|
if (unlikely(!page))
|
||||||
return FDMA_ERROR;
|
return FDMA_ERROR;
|
||||||
|
@ -450,7 +429,7 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx,
|
||||||
u64 timestamp;
|
u64 timestamp;
|
||||||
|
|
||||||
/* Get the received frame and unmap it */
|
/* Get the received frame and unmap it */
|
||||||
db = &fdma->dcbs[fdma->dcb_index].db[fdma->db_index];
|
db = fdma_db_next_get(fdma);
|
||||||
page = rx->page[fdma->dcb_index][fdma->db_index];
|
page = rx->page[fdma->dcb_index][fdma->db_index];
|
||||||
|
|
||||||
skb = build_skb(page_address(page), fdma->db_size);
|
skb = build_skb(page_address(page), fdma->db_size);
|
||||||
|
@ -508,7 +487,7 @@ static int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight)
|
||||||
|
|
||||||
/* Get all received skb */
|
/* Get all received skb */
|
||||||
while (counter < weight) {
|
while (counter < weight) {
|
||||||
if (!lan966x_fdma_rx_more_frames(rx))
|
if (!fdma_has_frames(fdma))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
|
@ -518,22 +497,22 @@ static int lan966x_fdma_napi_poll(struct napi_struct *napi, int weight)
|
||||||
break;
|
break;
|
||||||
case FDMA_ERROR:
|
case FDMA_ERROR:
|
||||||
lan966x_fdma_rx_free_page(rx);
|
lan966x_fdma_rx_free_page(rx);
|
||||||
lan966x_fdma_rx_advance_dcb(rx);
|
fdma_dcb_advance(fdma);
|
||||||
goto allocate_new;
|
goto allocate_new;
|
||||||
case FDMA_REDIRECT:
|
case FDMA_REDIRECT:
|
||||||
redirect = true;
|
redirect = true;
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case FDMA_TX:
|
case FDMA_TX:
|
||||||
lan966x_fdma_rx_advance_dcb(rx);
|
fdma_dcb_advance(fdma);
|
||||||
continue;
|
continue;
|
||||||
case FDMA_DROP:
|
case FDMA_DROP:
|
||||||
lan966x_fdma_rx_free_page(rx);
|
lan966x_fdma_rx_free_page(rx);
|
||||||
lan966x_fdma_rx_advance_dcb(rx);
|
fdma_dcb_advance(fdma);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb = lan966x_fdma_rx_get_frame(rx, src_port);
|
skb = lan966x_fdma_rx_get_frame(rx, src_port);
|
||||||
lan966x_fdma_rx_advance_dcb(rx);
|
fdma_dcb_advance(fdma);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
goto allocate_new;
|
goto allocate_new;
|
||||||
|
|
||||||
|
@ -597,7 +576,8 @@ static int lan966x_fdma_get_next_dcb(struct lan966x_tx *tx)
|
||||||
|
|
||||||
for (i = 0; i < fdma->n_dcbs; ++i) {
|
for (i = 0; i < fdma->n_dcbs; ++i) {
|
||||||
dcb_buf = &tx->dcbs_buf[i];
|
dcb_buf = &tx->dcbs_buf[i];
|
||||||
if (!dcb_buf->used && &fdma->dcbs[i] != fdma->last_dcb)
|
if (!dcb_buf->used &&
|
||||||
|
!fdma_is_last(&tx->fdma, &tx->fdma.dcbs[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue