Skip to content

Commit 29cc3a6

Browse files
DanielmachonPaolo Abeni
authored andcommitted
net: lan966x: use FDMA library for adding DCB's in the tx path
Use the fdma_dcb_add() function to add DCB's in the tx path. This gets rid of the open-coding of nextptr and dataptr handling and leaves it to the library. 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>
1 parent df2ddc1 commit 29cc3a6

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ static int lan966x_fdma_tx_dataptr_cb(struct fdma *fdma, int dcb, int db,
3333
return 0;
3434
}
3535

36+
static int lan966x_fdma_xdp_tx_dataptr_cb(struct fdma *fdma, int dcb, int db,
37+
u64 *dataptr)
38+
{
39+
struct lan966x *lan966x = (struct lan966x *)fdma->priv;
40+
41+
*dataptr = lan966x->tx.dcbs_buf[dcb].dma_addr + XDP_PACKET_HEADROOM;
42+
43+
return 0;
44+
}
45+
3646
static int lan966x_fdma_channel_active(struct lan966x *lan966x)
3747
{
3848
return lan_rd(lan966x, FDMA_CH_ACTIVE);
@@ -600,25 +610,6 @@ static int lan966x_fdma_get_next_dcb(struct lan966x_tx *tx)
600610
return -1;
601611
}
602612

603-
static void lan966x_fdma_tx_setup_dcb(struct lan966x_tx *tx,
604-
int next_to_use, int len,
605-
dma_addr_t dma_addr)
606-
{
607-
struct fdma_dcb *next_dcb;
608-
struct fdma_db *next_db;
609-
610-
next_dcb = &tx->fdma.dcbs[next_to_use];
611-
next_dcb->nextptr = FDMA_DCB_INVALID_DATA;
612-
613-
next_db = &next_dcb->db[0];
614-
next_db->dataptr = dma_addr;
615-
next_db->status = FDMA_DCB_STATUS_SOF |
616-
FDMA_DCB_STATUS_EOF |
617-
FDMA_DCB_STATUS_INTR |
618-
FDMA_DCB_STATUS_BLOCKO(0) |
619-
FDMA_DCB_STATUS_BLOCKL(len);
620-
}
621-
622613
static void lan966x_fdma_tx_start(struct lan966x_tx *tx, int next_to_use)
623614
{
624615
struct lan966x *lan966x = tx->lan966x;
@@ -692,11 +683,6 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, void *ptr, u32 len)
692683

693684
next_dcb_buf->data.xdpf = xdpf;
694685
next_dcb_buf->len = xdpf->len + IFH_LEN_BYTES;
695-
696-
/* Setup next dcb */
697-
lan966x_fdma_tx_setup_dcb(tx, next_to_use,
698-
xdpf->len + IFH_LEN_BYTES,
699-
dma_addr);
700686
} else {
701687
page = ptr;
702688

@@ -713,11 +699,6 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, void *ptr, u32 len)
713699

714700
next_dcb_buf->data.page = page;
715701
next_dcb_buf->len = len + IFH_LEN_BYTES;
716-
717-
/* Setup next dcb */
718-
lan966x_fdma_tx_setup_dcb(tx, next_to_use,
719-
len + IFH_LEN_BYTES,
720-
dma_addr + XDP_PACKET_HEADROOM);
721702
}
722703

723704
/* Fill up the buffer */
@@ -728,6 +709,17 @@ int lan966x_fdma_xmit_xdpf(struct lan966x_port *port, void *ptr, u32 len)
728709
next_dcb_buf->ptp = false;
729710
next_dcb_buf->dev = port->dev;
730711

712+
__fdma_dcb_add(&tx->fdma,
713+
next_to_use,
714+
0,
715+
FDMA_DCB_STATUS_INTR |
716+
FDMA_DCB_STATUS_SOF |
717+
FDMA_DCB_STATUS_EOF |
718+
FDMA_DCB_STATUS_BLOCKO(0) |
719+
FDMA_DCB_STATUS_BLOCKL(next_dcb_buf->len),
720+
&fdma_nextptr_cb,
721+
&lan966x_fdma_xdp_tx_dataptr_cb);
722+
731723
/* Start the transmission */
732724
lan966x_fdma_tx_start(tx, next_to_use);
733725

@@ -787,9 +779,6 @@ int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev)
787779
goto release;
788780
}
789781

790-
/* Setup next dcb */
791-
lan966x_fdma_tx_setup_dcb(tx, next_to_use, skb->len, dma_addr);
792-
793782
/* Fill up the buffer */
794783
next_dcb_buf = &tx->dcbs_buf[next_to_use];
795784
next_dcb_buf->use_skb = true;
@@ -801,6 +790,15 @@ int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev)
801790
next_dcb_buf->ptp = false;
802791
next_dcb_buf->dev = dev;
803792

793+
fdma_dcb_add(&tx->fdma,
794+
next_to_use,
795+
0,
796+
FDMA_DCB_STATUS_INTR |
797+
FDMA_DCB_STATUS_SOF |
798+
FDMA_DCB_STATUS_EOF |
799+
FDMA_DCB_STATUS_BLOCKO(0) |
800+
FDMA_DCB_STATUS_BLOCKL(skb->len));
801+
804802
if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
805803
LAN966X_SKB_CB(skb)->rew_op == IFH_REW_OP_TWO_STEP_PTP)
806804
next_dcb_buf->ptp = true;

0 commit comments

Comments
 (0)