lkml.org 
[lkml]   [2019]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH RFC net-next 10/19] net: dsa: tag_gswip: add GRO callbacks
    Date
    ...so that GRO layer can now correctly process GSWIP-tagged frames.

    Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
    ---
    net/dsa/tag_gswip.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 74 insertions(+)

    diff --git a/net/dsa/tag_gswip.c b/net/dsa/tag_gswip.c
    index e7b36de27fd8..56e754bd434a 100644
    --- a/net/dsa/tag_gswip.c
    +++ b/net/dsa/tag_gswip.c
    @@ -114,12 +114,86 @@ static void gswip_tag_flow_dissect(const struct sk_buff *skb, __be16 *proto,
    *proto = gswip_tag_encap_proto(skb->data);
    }

    +static struct sk_buff *gswip_tag_gro_receive(struct list_head *head,
    + struct sk_buff *skb)
    +{
    + const struct packet_offload *ptype;
    + struct sk_buff *p, *pp = NULL;
    + u32 data_off, data_end;
    + const u8 *data;
    + int flush = 1;
    +
    + data_off = skb_gro_offset(skb);
    + data_end = data_off + GSWIP_RX_HEADER_LEN;
    +
    + data = skb_gro_header_fast(skb, data_off);
    + if (skb_gro_header_hard(skb, data_end)) {
    + data = skb_gro_header_slow(skb, data_end, data_off);
    + if (unlikely(!data))
    + goto out;
    + }
    +
    + rcu_read_lock();
    +
    + ptype = gro_find_receive_by_type(gswip_tag_encap_proto(data));
    + if (!ptype)
    + goto out_unlock;
    +
    + flush = 0;
    +
    + list_for_each_entry(p, head, list) {
    + if (!NAPI_GRO_CB(p)->same_flow)
    + continue;
    +
    + /* Data that is to the left to the current position is already
    + * pulled to the head
    + */
    + if (gswip_tag_source_port(skb->data + data_off) ^
    + gswip_tag_source_port(p->data + data_off))
    + NAPI_GRO_CB(p)->same_flow = 0;
    + }
    +
    + skb_gro_pull(skb, GSWIP_RX_HEADER_LEN);
    + skb_gro_postpull_rcsum(skb, data, GSWIP_RX_HEADER_LEN);
    +
    + pp = call_gro_receive(ptype->callbacks.gro_receive, head, skb);
    +
    +out_unlock:
    + rcu_read_unlock();
    +out:
    + skb_gro_flush_final(skb, pp, flush);
    +
    + return pp;
    +}
    +
    +static int gswip_tag_gro_complete(struct sk_buff *skb, int nhoff)
    +{
    + const struct packet_offload *ptype;
    + int err = -ENOENT;
    + __be16 proto;
    +
    + proto = gswip_tag_encap_proto(skb->data + nhoff);
    + nhoff += GSWIP_RX_HEADER_LEN;
    +
    + rcu_read_lock();
    +
    + ptype = gro_find_complete_by_type(proto);
    + if (ptype)
    + err = ptype->callbacks.gro_complete(skb, nhoff);
    +
    + rcu_read_unlock();
    +
    + return err;
    +}
    +
    static const struct dsa_device_ops gswip_netdev_ops = {
    .name = "gswip",
    .proto = DSA_TAG_PROTO_GSWIP,
    .xmit = gswip_tag_xmit,
    .rcv = gswip_tag_rcv,
    .flow_dissect = gswip_tag_flow_dissect,
    + .gro_receive = gswip_tag_gro_receive,
    + .gro_complete = gswip_tag_gro_complete,
    .overhead = GSWIP_RX_HEADER_LEN,
    };

    --
    2.24.1
    \
     
     \ /
      Last update: 2019-12-30 15:34    [W:8.038 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site