net: Switch to using the new packet offload infrustructure
Convert to using the new GSO/GRO registration mechanism and new packet offload structure. Signed-off-by: Vlad Yasevich <vyasevic@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
					parent
					
						
							
								62532da9d5
							
						
					
				
			
			
				commit
				
					
						22061d8014
					
				
			
		
					 4 changed files with 20 additions and 16 deletions
				
			
		| 
						 | 
					@ -1509,12 +1509,6 @@ struct packet_type {
 | 
				
			||||||
					 struct net_device *,
 | 
										 struct net_device *,
 | 
				
			||||||
					 struct packet_type *,
 | 
										 struct packet_type *,
 | 
				
			||||||
					 struct net_device *);
 | 
										 struct net_device *);
 | 
				
			||||||
	struct sk_buff		*(*gso_segment)(struct sk_buff *skb,
 | 
					 | 
				
			||||||
						netdev_features_t features);
 | 
					 | 
				
			||||||
	int			(*gso_send_check)(struct sk_buff *skb);
 | 
					 | 
				
			||||||
	struct sk_buff		**(*gro_receive)(struct sk_buff **head,
 | 
					 | 
				
			||||||
					       struct sk_buff *skb);
 | 
					 | 
				
			||||||
	int			(*gro_complete)(struct sk_buff *skb);
 | 
					 | 
				
			||||||
	bool			(*id_match)(struct packet_type *ptype,
 | 
						bool			(*id_match)(struct packet_type *ptype,
 | 
				
			||||||
					    struct sock *sk);
 | 
										    struct sock *sk);
 | 
				
			||||||
	void			*af_packet_priv;
 | 
						void			*af_packet_priv;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2072,7 +2072,7 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb,
 | 
				
			||||||
	netdev_features_t features)
 | 
						netdev_features_t features)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
 | 
						struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
 | 
				
			||||||
	struct packet_type *ptype;
 | 
						struct packet_offload *ptype;
 | 
				
			||||||
	__be16 type = skb->protocol;
 | 
						__be16 type = skb->protocol;
 | 
				
			||||||
	int vlan_depth = ETH_HLEN;
 | 
						int vlan_depth = ETH_HLEN;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
| 
						 | 
					@ -2101,9 +2101,8 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rcu_read_lock();
 | 
						rcu_read_lock();
 | 
				
			||||||
	list_for_each_entry_rcu(ptype,
 | 
						list_for_each_entry_rcu(ptype, &offload_base, list) {
 | 
				
			||||||
			&ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) {
 | 
							if (ptype->type == type && ptype->gso_segment) {
 | 
				
			||||||
		if (ptype->type == type && !ptype->dev && ptype->gso_segment) {
 | 
					 | 
				
			||||||
			if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
 | 
								if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
 | 
				
			||||||
				err = ptype->gso_send_check(skb);
 | 
									err = ptype->gso_send_check(skb);
 | 
				
			||||||
				segs = ERR_PTR(err);
 | 
									segs = ERR_PTR(err);
 | 
				
			||||||
| 
						 | 
					@ -3522,9 +3521,9 @@ static void flush_backlog(void *arg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int napi_gro_complete(struct sk_buff *skb)
 | 
					static int napi_gro_complete(struct sk_buff *skb)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct packet_type *ptype;
 | 
						struct packet_offload *ptype;
 | 
				
			||||||
	__be16 type = skb->protocol;
 | 
						__be16 type = skb->protocol;
 | 
				
			||||||
	struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
 | 
						struct list_head *head = &offload_base;
 | 
				
			||||||
	int err = -ENOENT;
 | 
						int err = -ENOENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (NAPI_GRO_CB(skb)->count == 1) {
 | 
						if (NAPI_GRO_CB(skb)->count == 1) {
 | 
				
			||||||
| 
						 | 
					@ -3534,7 +3533,7 @@ static int napi_gro_complete(struct sk_buff *skb)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rcu_read_lock();
 | 
						rcu_read_lock();
 | 
				
			||||||
	list_for_each_entry_rcu(ptype, head, list) {
 | 
						list_for_each_entry_rcu(ptype, head, list) {
 | 
				
			||||||
		if (ptype->type != type || ptype->dev || !ptype->gro_complete)
 | 
							if (ptype->type != type || !ptype->gro_complete)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err = ptype->gro_complete(skb);
 | 
							err = ptype->gro_complete(skb);
 | 
				
			||||||
| 
						 | 
					@ -3584,9 +3583,9 @@ EXPORT_SYMBOL(napi_gro_flush);
 | 
				
			||||||
enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 | 
					enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sk_buff **pp = NULL;
 | 
						struct sk_buff **pp = NULL;
 | 
				
			||||||
	struct packet_type *ptype;
 | 
						struct packet_offload *ptype;
 | 
				
			||||||
	__be16 type = skb->protocol;
 | 
						__be16 type = skb->protocol;
 | 
				
			||||||
	struct list_head *head = &ptype_base[ntohs(type) & PTYPE_HASH_MASK];
 | 
						struct list_head *head = &offload_base;
 | 
				
			||||||
	int same_flow;
 | 
						int same_flow;
 | 
				
			||||||
	int mac_len;
 | 
						int mac_len;
 | 
				
			||||||
	enum gro_result ret;
 | 
						enum gro_result ret;
 | 
				
			||||||
| 
						 | 
					@ -3599,7 +3598,7 @@ enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rcu_read_lock();
 | 
						rcu_read_lock();
 | 
				
			||||||
	list_for_each_entry_rcu(ptype, head, list) {
 | 
						list_for_each_entry_rcu(ptype, head, list) {
 | 
				
			||||||
		if (ptype->type != type || ptype->dev || !ptype->gro_receive)
 | 
							if (ptype->type != type || !ptype->gro_receive)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		skb_set_network_header(skb, skb_gro_offset(skb));
 | 
							skb_set_network_header(skb, skb_gro_offset(skb));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1662,6 +1662,10 @@ static int ipv4_proc_init(void);
 | 
				
			||||||
static struct packet_type ip_packet_type __read_mostly = {
 | 
					static struct packet_type ip_packet_type __read_mostly = {
 | 
				
			||||||
	.type = cpu_to_be16(ETH_P_IP),
 | 
						.type = cpu_to_be16(ETH_P_IP),
 | 
				
			||||||
	.func = ip_rcv,
 | 
						.func = ip_rcv,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct packet_offload ip_packet_offload __read_mostly = {
 | 
				
			||||||
 | 
						.type = cpu_to_be16(ETH_P_IP),
 | 
				
			||||||
	.gso_send_check = inet_gso_send_check,
 | 
						.gso_send_check = inet_gso_send_check,
 | 
				
			||||||
	.gso_segment = inet_gso_segment,
 | 
						.gso_segment = inet_gso_segment,
 | 
				
			||||||
	.gro_receive = inet_gro_receive,
 | 
						.gro_receive = inet_gro_receive,
 | 
				
			||||||
| 
						 | 
					@ -1781,6 +1785,7 @@ static int __init inet_init(void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ipfrag_init();
 | 
						ipfrag_init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dev_add_offload(&ip_packet_offload);
 | 
				
			||||||
	dev_add_pack(&ip_packet_type);
 | 
						dev_add_pack(&ip_packet_type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = 0;
 | 
						rc = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -938,6 +938,10 @@ out_unlock:
 | 
				
			||||||
static struct packet_type ipv6_packet_type __read_mostly = {
 | 
					static struct packet_type ipv6_packet_type __read_mostly = {
 | 
				
			||||||
	.type = cpu_to_be16(ETH_P_IPV6),
 | 
						.type = cpu_to_be16(ETH_P_IPV6),
 | 
				
			||||||
	.func = ipv6_rcv,
 | 
						.func = ipv6_rcv,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct packet_offload ipv6_packet_offload __read_mostly = {
 | 
				
			||||||
 | 
						.type = cpu_to_be16(ETH_P_IPV6),
 | 
				
			||||||
	.gso_send_check = ipv6_gso_send_check,
 | 
						.gso_send_check = ipv6_gso_send_check,
 | 
				
			||||||
	.gso_segment = ipv6_gso_segment,
 | 
						.gso_segment = ipv6_gso_segment,
 | 
				
			||||||
	.gro_receive = ipv6_gro_receive,
 | 
						.gro_receive = ipv6_gro_receive,
 | 
				
			||||||
| 
						 | 
					@ -946,6 +950,7 @@ static struct packet_type ipv6_packet_type __read_mostly = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __init ipv6_packet_init(void)
 | 
					static int __init ipv6_packet_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						dev_add_offload(&ipv6_packet_offload);
 | 
				
			||||||
	dev_add_pack(&ipv6_packet_type);
 | 
						dev_add_pack(&ipv6_packet_type);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -953,6 +958,7 @@ static int __init ipv6_packet_init(void)
 | 
				
			||||||
static void ipv6_packet_cleanup(void)
 | 
					static void ipv6_packet_cleanup(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	dev_remove_pack(&ipv6_packet_type);
 | 
						dev_remove_pack(&ipv6_packet_type);
 | 
				
			||||||
 | 
						dev_remove_offload(&ipv6_packet_offload);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __net_init ipv6_init_mibs(struct net *net)
 | 
					static int __net_init ipv6_init_mibs(struct net *net)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue