Skip to content

Commit

Permalink
net: Use skb accessors in network drivers
Browse files Browse the repository at this point in the history
In preparation for unifying the skb_frag and bio_vec, use the fine
accessors which already exist and use skb_frag_t instead of
struct skb_frag_struct.

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and davem330 committed Jul 23, 2019
1 parent 7e24b4e commit d784097
Show file tree
Hide file tree
Showing 69 changed files with 149 additions and 164 deletions.
6 changes: 4 additions & 2 deletions drivers/crypto/chelsio/chtls/chtls_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,9 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
}
/* Update the skb. */
if (merge) {
skb_shinfo(skb)->frags[i - 1].size += copy;
skb_frag_size_add(
&skb_shinfo(skb)->frags[i - 1],
copy);
} else {
skb_fill_page_desc(skb, i, page, off, copy);
if (off + copy < pg_size) {
Expand Down Expand Up @@ -1247,7 +1249,7 @@ int chtls_sendpage(struct sock *sk, struct page *page,

i = skb_shinfo(skb)->nr_frags;
if (skb_can_coalesce(skb, i, page, offset)) {
skb_shinfo(skb)->frags[i - 1].size += copy;
skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy);
} else if (i < MAX_SKB_FRAGS) {
get_page(page);
skb_fill_page_desc(skb, i, page, offset, copy);
Expand Down
3 changes: 2 additions & 1 deletion drivers/hsi/clients/ssi_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ static void ssip_skb_to_msg(struct sk_buff *skb, struct hsi_msg *msg)
sg = sg_next(sg);
BUG_ON(!sg);
frag = &skb_shinfo(skb)->frags[i];
sg_set_page(sg, frag->page.p, frag->size, frag->page_offset);
sg_set_page(sg, skb_frag_page(frag), skb_frag_size(frag),
frag->page_offset);
}
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/hfi1/vnic_sdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static noinline int build_vnic_ulp_payload(struct sdma_engine *sde,
goto bail_txadd;

for (i = 0; i < skb_shinfo(tx->skb)->nr_frags; i++) {
struct skb_frag_struct *frag = &skb_shinfo(tx->skb)->frags[i];
skb_frag_t *frag = &skb_shinfo(tx->skb)->frags[i];

/* combine physically continuous fragments later? */
ret = sdma_txadd_page(sde->dd,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/3com/3c59x.c
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)

dma_addr = skb_frag_dma_map(vp->gendev, frag,
0,
frag->size,
skb_frag_size(frag),
DMA_TO_DEVICE);
if (dma_mapping_error(vp->gendev, dma_addr)) {
for(i = i-1; i >= 0; i--)
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/agere/et131x.c
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
u32 thiscopy, remainder;
struct sk_buff *skb = tcb->skb;
u32 nr_frags = skb_shinfo(skb)->nr_frags + 1;
struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0];
skb_frag_t *frags = &skb_shinfo(skb)->frags[0];
struct phy_device *phydev = adapter->netdev->phydev;
dma_addr_t dma_addr;
struct tx_ring *tx_ring = &adapter->tx_ring;
Expand Down Expand Up @@ -2488,11 +2488,11 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
frag++;
}
} else {
desc[frag].len_vlan = frags[i - 1].size;
desc[frag].len_vlan = skb_frag_size(&frags[i - 1]);
dma_addr = skb_frag_dma_map(&adapter->pdev->dev,
&frags[i - 1],
0,
frags[i - 1].size,
desc[frag].len_vlan,
DMA_TO_DEVICE);
desc[frag].addr_lo = lower_32_bits(dma_addr);
desc[frag].addr_hi = upper_32_bits(dma_addr);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe-desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ static int xgbe_map_tx_skb(struct xgbe_channel *channel, struct sk_buff *skb)
struct xgbe_ring *ring = channel->tx_ring;
struct xgbe_ring_data *rdata;
struct xgbe_packet_data *packet;
struct skb_frag_struct *frag;
skb_frag_t *frag;
dma_addr_t skb_dma;
unsigned int start_index, cur_index;
unsigned int offset, tso, vlan, datalen, len;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,7 @@ static void xgbe_packet_info(struct xgbe_prv_data *pdata,
struct xgbe_ring *ring, struct sk_buff *skb,
struct xgbe_packet_data *packet)
{
struct skb_frag_struct *frag;
skb_frag_t *frag;
unsigned int context_desc;
unsigned int len;
unsigned int i;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ static int xgene_enet_work_msg(struct sk_buff *skb, u64 *hopinfo)
nr_frags = skb_shinfo(skb)->nr_frags;

for (i = 0; i < 2 && i < nr_frags; i++)
len += skb_shinfo(skb)->frags[i].size;
len += skb_frag_size(
&skb_shinfo(skb)->frags[i]);

/* HW requires header must reside in 3 buffer */
if (unlikely(hdr_len > len)) {
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/atheros/alx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,7 @@ static int alx_map_tx_skb(struct alx_tx_queue *txq, struct sk_buff *skb)
tpd->len = cpu_to_le16(maplen);

for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) {
struct skb_frag_struct *frag;

frag = &skb_shinfo(skb)->frags[f];
skb_frag_t *frag = &skb_shinfo(skb)->frags[f];

if (++txq->write_idx == txq->count)
txq->write_idx = 0;
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/atheros/atl1c/atl1c_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2150,9 +2150,7 @@ static int atl1c_tx_map(struct atl1c_adapter *adapter,
}

for (f = 0; f < nr_frags; f++) {
struct skb_frag_struct *frag;

frag = &skb_shinfo(skb)->frags[f];
skb_frag_t *frag = &skb_shinfo(skb)->frags[f];

use_tpd = atl1c_get_tpd(adapter, type);
memcpy(use_tpd, tpd, sizeof(struct atl1c_tpd_desc));
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/atheros/atl1e/atl1e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,11 +1770,10 @@ static int atl1e_tx_map(struct atl1e_adapter *adapter,
}

for (f = 0; f < nr_frags; f++) {
const struct skb_frag_struct *frag;
const skb_frag_t *frag = &skb_shinfo(skb)->frags[f];
u16 i;
u16 seg_num;

frag = &skb_shinfo(skb)->frags[f];
buf_len = skb_frag_size(frag);

seg_num = (buf_len + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/atheros/atlx/atl1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,10 +2256,9 @@ static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb,
}

for (f = 0; f < nr_frags; f++) {
const struct skb_frag_struct *frag;
const skb_frag_t *frag = &skb_shinfo(skb)->frags[f];
u16 i, nseg;

frag = &skb_shinfo(skb)->frags[f];
buf_len = skb_frag_size(frag);

nseg = (buf_len + ATL1_MAX_TX_BUF_LEN - 1) /
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
flags = 0;

for (i = 0; i < nr_frags; i++) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
int len = skb_frag_size(frag);

index = (index + 1) % BGMAC_TX_RING_SLOTS;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ static struct sk_buff *bnxt_rx_page_skb(struct bnxt *bp,
{
unsigned int payload = offset_and_len >> 16;
unsigned int len = offset_and_len & 0xffff;
struct skb_frag_struct *frag;
skb_frag_t *frag;
struct page *page = data;
u16 prod = rxr->rx_prod;
struct sk_buff *skb;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/brocade/bna/bnad.c
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
head_unmap->nvecs++;

for (i = 0, vect_id = 0; i < vectors - 1; i++) {
const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
u32 size = skb_frag_size(frag);

if (unlikely(size == 0)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/calxeda/xgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ static netdev_tx_t xgmac_xmit(struct sk_buff *skb, struct net_device *dev)
for (i = 0; i < nfrags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];

len = frag->size;
len = skb_frag_size(frag);

paddr = skb_frag_dma_map(priv->device, frag, 0, len,
DMA_TO_DEVICE);
Expand Down
23 changes: 11 additions & 12 deletions drivers/net/ethernet/cavium/liquidio/lio_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1492,11 +1492,11 @@ static void free_netsgbuf(void *buf)

i = 1;
while (frags--) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];

pci_unmap_page((lio->oct_dev)->pci_dev,
g->sg[(i >> 2)].ptr[(i & 3)],
frag->size, DMA_TO_DEVICE);
skb_frag_size(frag), DMA_TO_DEVICE);
i++;
}

Expand Down Expand Up @@ -1535,11 +1535,11 @@ static void free_netsgbuf_with_resp(void *buf)

i = 1;
while (frags--) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];

pci_unmap_page((lio->oct_dev)->pci_dev,
g->sg[(i >> 2)].ptr[(i & 3)],
frag->size, DMA_TO_DEVICE);
skb_frag_size(frag), DMA_TO_DEVICE);
i++;
}

Expand Down Expand Up @@ -2424,7 +2424,7 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)

} else {
int i, frags;
struct skb_frag_struct *frag;
skb_frag_t *frag;
struct octnic_gather *g;

spin_lock(&lio->glist_lock[q_idx]);
Expand Down Expand Up @@ -2462,11 +2462,9 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
frag = &skb_shinfo(skb)->frags[i - 1];

g->sg[(i >> 2)].ptr[(i & 3)] =
dma_map_page(&oct->pci_dev->dev,
frag->page.p,
frag->page_offset,
frag->size,
DMA_TO_DEVICE);
skb_frag_dma_map(&oct->pci_dev->dev,
frag, 0, skb_frag_size(frag),
DMA_TO_DEVICE);

if (dma_mapping_error(&oct->pci_dev->dev,
g->sg[i >> 2].ptr[i & 3])) {
Expand All @@ -2478,15 +2476,16 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
frag = &skb_shinfo(skb)->frags[j - 1];
dma_unmap_page(&oct->pci_dev->dev,
g->sg[j >> 2].ptr[j & 3],
frag->size,
skb_frag_size(frag),
DMA_TO_DEVICE);
}
dev_err(&oct->pci_dev->dev, "%s DMA mapping error 3\n",
__func__);
return NETDEV_TX_BUSY;
}

add_sg_size(&g->sg[(i >> 2)], frag->size, (i & 3));
add_sg_size(&g->sg[(i >> 2)], skb_frag_size(frag),
(i & 3));
i++;
}

Expand Down
23 changes: 11 additions & 12 deletions drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,11 @@ static void free_netsgbuf(void *buf)

i = 1;
while (frags--) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];

pci_unmap_page((lio->oct_dev)->pci_dev,
g->sg[(i >> 2)].ptr[(i & 3)],
frag->size, DMA_TO_DEVICE);
skb_frag_size(frag), DMA_TO_DEVICE);
i++;
}

Expand Down Expand Up @@ -881,11 +881,11 @@ static void free_netsgbuf_with_resp(void *buf)

i = 1;
while (frags--) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];

pci_unmap_page((lio->oct_dev)->pci_dev,
g->sg[(i >> 2)].ptr[(i & 3)],
frag->size, DMA_TO_DEVICE);
skb_frag_size(frag), DMA_TO_DEVICE);
i++;
}

Expand Down Expand Up @@ -1497,7 +1497,7 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
ndata.reqtype = REQTYPE_NORESP_NET;

} else {
struct skb_frag_struct *frag;
skb_frag_t *frag;
struct octnic_gather *g;
int i, frags;

Expand Down Expand Up @@ -1535,11 +1535,9 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
frag = &skb_shinfo(skb)->frags[i - 1];

g->sg[(i >> 2)].ptr[(i & 3)] =
dma_map_page(&oct->pci_dev->dev,
frag->page.p,
frag->page_offset,
frag->size,
DMA_TO_DEVICE);
skb_frag_dma_map(&oct->pci_dev->dev,
frag, 0, skb_frag_size(frag),
DMA_TO_DEVICE);
if (dma_mapping_error(&oct->pci_dev->dev,
g->sg[i >> 2].ptr[i & 3])) {
dma_unmap_single(&oct->pci_dev->dev,
Expand All @@ -1550,15 +1548,16 @@ static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
frag = &skb_shinfo(skb)->frags[j - 1];
dma_unmap_page(&oct->pci_dev->dev,
g->sg[j >> 2].ptr[j & 3],
frag->size,
skb_frag_size(frag),
DMA_TO_DEVICE);
}
dev_err(&oct->pci_dev->dev, "%s DMA mapping error 3\n",
__func__);
return NETDEV_TX_BUSY;
}

add_sg_size(&g->sg[(i >> 2)], frag->size, (i & 3));
add_sg_size(&g->sg[(i >> 2)], skb_frag_size(frag),
(i & 3));
i++;
}

Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/cavium/thunder/nicvf_queues.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,9 +1588,7 @@ int nicvf_sq_append_skb(struct nicvf *nic, struct snd_queue *sq,
goto doorbell;

for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
const struct skb_frag_struct *frag;

frag = &skb_shinfo(skb)->frags[i];
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];

qentry = nicvf_get_nxt_sqentry(sq, qentry);
size = skb_frag_size(frag);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ static void lro_add_page(struct adapter *adap, struct sge_qset *qs,
struct port_info *pi = netdev_priv(qs->netdev);
struct sk_buff *skb = NULL;
struct cpl_rx_pkt *cpl;
struct skb_frag_struct *rx_frag;
skb_frag_t *rx_frag;
int nr_frags;
int offset = 0;

Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ethernet/cortina/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,9 +1182,8 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb,
buflen = skb_headlen(skb);
} else {
skb_frag = skb_si->frags + frag;
buffer = page_address(skb_frag_page(skb_frag)) +
skb_frag->page_offset;
buflen = skb_frag->size;
buffer = skb_frag_address(skb_frag);
buflen = skb_frag_size(skb_frag);
}

if (frag == last_frag) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ static u32 be_xmit_enqueue(struct be_adapter *adapter, struct be_tx_obj *txo,
}

for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
len = skb_frag_size(frag);

busaddr = skb_frag_dma_map(dev, frag, 0, len, DMA_TO_DEVICE);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/freescale/enetc/enetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb,
int active_offloads)
{
struct enetc_tx_swbd *tx_swbd;
struct skb_frag_struct *frag;
skb_frag_t *frag;
int len = skb_headlen(skb);
union enetc_tx_bd temp_bd;
union enetc_tx_bd *txbd;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/fec_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
status = fec16_to_cpu(bdp->cbd_sc);
status &= ~BD_ENET_TX_STATS;
status |= (BD_ENET_TX_TC | BD_ENET_TX_READY);
frag_len = skb_shinfo(skb)->frags[frag].size;
frag_len = skb_frag_size(&skb_shinfo(skb)->frags[frag]);

/* Handle the last BD specially */
if (frag == nr_frags - 1) {
Expand All @@ -387,7 +387,7 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq,
ebdp->cbd_esc = cpu_to_fec32(estatus);
}

bufaddr = page_address(this_frag->page.p) + this_frag->page_offset;
bufaddr = skb_frag_address(this_frag);

index = fec_enet_get_bd_index(bdp, &txq->bd);
if (((unsigned long) bufaddr) & fep->tx_align ||
Expand Down
Loading

0 comments on commit d784097

Please sign in to comment.