Skip to contentSkip to conversation

net: qualcomm: rmnet: Updates 2018-03-12

PATCH Superseded Subash Abhinov Kasiviswanathan 2 participants 7 messages Mar 13, 2018

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover net: qualcomm: rmnet: Updates 2018-03-12

This series contains some minor updates for rmnet driver.

Patch 1 contains fixes for sparse warnings.
Patch 2 updates the copyright date to 2018.
Patch 3 is a cleanup in receive path.
Patch 4 has the implementation of the fill_info operation.

Subash Abhinov Kasiviswanathan (4):
net: qualcomm: rmnet: Fix casting issues
net: qualcomm: rmnet: Update copyright year to 2018
net: qualcomm: rmnet: Remove unnecessary device assignment
net: qualcomm: rmnet: Implement fill_info

 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 32 +++++++++++++++++++++-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h |  2 +-
 .../net/ethernet/qualcomm/rmnet/rmnet_handlers.c   |  2 +-
 .../net/ethernet/qualcomm/rmnet/rmnet_handlers.h   |  2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h    |  4 +--
 .../ethernet/qualcomm/rmnet/rmnet_map_command.c    |  6 ++--
 .../net/ethernet/qualcomm/rmnet/rmnet_map_data.c   |  8 +++---
 .../net/ethernet/qualcomm/rmnet/rmnet_private.h    |  2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c    |  2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h    |  2 +-
 10 files changed, 46 insertions(+), 16 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 net: qualcomm: rmnet: Fix casting issues

Fix warnings which were reported when running with sparse (make C=1 CF=-D__CHECK_ENDIAN__)

drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c:81:15:
warning: cast to restricted __be16 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:271:37:
warning: incorrect type in assignment (different base types) expected unsigned short [unsigned] [usertype] pkt_len got restricted __be16 [usertype] <noident> drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:287:29:
warning: incorrect type in assignment (different base types) expected unsigned short [unsigned] [usertype] pkt_len got restricted __be16 [usertype] <noident> drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:310:22:
warning: cast to restricted __be16 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c:319:13:
warning: cast to restricted __be16 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:49:18:
warning: cast to restricted __be16 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:50:18:
warning: cast to restricted __be32 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:74:21:
warning: cast to restricted __be16

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h         | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 4 ++--
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c    | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +1 -1
index 6ce31e2..65b074e 100644
@@ -44,7 +44,7 @@ struct rmnet_map_header {
 	u8  reserved_bit:1;
 	u8  cd_bit:1;
 	u8  mux_id;
-	u16 pkt_len;
+	__be16 pkt_len;
 }  __aligned(1);
 
 struct rmnet_map_dl_csum_trailer {
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +2 -2
index b0dbca0..b39b73b 100644
@@ -46,8 +46,8 @@ static u8 rmnet_map_do_flow_control(struct sk_buff *skb,
 	vnd = ep->egress_dev;
 
 	ip_family = cmd->flow_control.ip_family;
-	fc_seq = ntohs(cmd->flow_control.flow_control_seq_num);
-	qos_id = ntohl(cmd->flow_control.qos_id);
+	fc_seq = ntohs((__force __be16)cmd->flow_control.flow_control_seq_num);
+	qos_id = ntohl((__force __be32)cmd->flow_control.qos_id);
 
 	/* Ignore the ip family and pass the sequence number for both v4 and v6
 	 * sequence. User space does not support creating dedicated flows for
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +3 -2
index c74a6c5..4e342a3 100644
@@ -307,7 +307,8 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
 		return NULL;
 
 	maph = (struct rmnet_map_header *)skb->data;
-	packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header);
+	packet_len = ntohs((__force __be16)maph->pkt_len) +
+		     sizeof(struct rmnet_map_header);
 
 	if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4)
 		packet_len += sizeof(struct rmnet_map_dl_csum_trailer);
@@ -316,7 +317,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
 		return NULL;
 
 	/* Some hardware can send us empty frames. Catch them */
-	if (ntohs(maph->pkt_len) == 0)
+	if (ntohs((__force __be16)maph->pkt_len) == 0)
 		return NULL;
 
 	skbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, GFP_ATOMIC);
Signature · 1 line
1.9.1
#4 lore raw

PATCH 2/4 net: qualcomm: rmnet: Update copyright year to 2018

In reply to Subash Abhinov Kasiviswanathan
---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c      | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h      | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c    | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h    | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h         | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c    | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h     | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c         | 2 +-
 drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h         | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +1 -1
index c494918..096301a 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +1 -1
index 00e4634..0b5b5da 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2016-2018 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c +1 -1
index 601edec..c758248 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.h +1 -1
index 3537e4c..1bc6828 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2016-2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013, 2016-2018 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +1 -1
index 65b074e..2aaf093 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c +1 -1
index b39b73b..88f2595 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +1 -1
index 4e342a3..fad3d0b 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h +1 -1
index de0143e..98365ef 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2016-2018 The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +1 -1
index 346d310..2ea16a0 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h +1 -1
index 71e4c32..daab75c 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
Signature · 1 line
1.9.1
#5 lore raw

PATCH 3/4 net: qualcomm: rmnet: Remove unnecessary device assignment

In reply to Subash Abhinov Kasiviswanathan

Device of the de-aggregated skb is correctly assigned after inspecting the mux_id, so remove the assignment in rmnet_map_deaggregate().

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +0 -1
index fad3d0b..134da43 100644
@@ -324,7 +324,6 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
 	if (!skbn)
 		return NULL;
 
-	skbn->dev = skb->dev;
 	skb_reserve(skbn, RMNET_MAP_DEAGGR_HEADROOM);
 	skb_put(skbn, packet_len);
 	memcpy(skbn->data, skb->data, packet_len);
Signature · 1 line
1.9.1
#6 lore raw

PATCH 4/4 net: qualcomm: rmnet: Implement fill_info

In reply to Subash Abhinov Kasiviswanathan

This is needed to query the mux_id and flags of a rmnet device.

---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +30 -0
index 096301a..d0f3e0f 100644
@@ -331,6 +331,35 @@ static size_t rmnet_get_size(const struct net_device *dev)
 	       nla_total_size(sizeof(struct ifla_vlan_flags)); /* IFLA_VLAN_FLAGS */
 }
 
+static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev)
+{
+	struct rmnet_priv *priv = netdev_priv(dev);
+	struct net_device *real_dev;
+	struct ifla_vlan_flags f;
+	struct rmnet_port *port;
+
+	real_dev = priv->real_dev;
+
+	if (!rmnet_is_real_dev_registered(real_dev))
+		return -ENODEV;
+
+	if (nla_put_u16(skb, IFLA_VLAN_ID, priv->mux_id))
+		goto nla_put_failure;
+
+	port = rmnet_get_port_rtnl(real_dev);
+
+	f.flags = port->data_format;
+	f.mask  = ~0;
+
+	if (nla_put(skb, IFLA_VLAN_FLAGS, sizeof(f), &f))
+		goto nla_put_failure;
+
+	return 0;
+
+nla_put_failure:
+	return -EMSGSIZE;
+}
+
 struct rtnl_link_ops rmnet_link_ops __read_mostly = {
 	.kind		= "rmnet",
 	.maxtype	= __IFLA_VLAN_MAX,
@@ -341,6 +370,7 @@ struct rtnl_link_ops rmnet_link_ops __read_mostly = {
 	.dellink	= rmnet_dellink,
 	.get_size	= rmnet_get_size,
 	.changelink     = rmnet_changelink,
+	.fill_info	= rmnet_fill_info,
 };
 
 /* Needs either rcu_read_lock() or rtnl lock */
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [PATCH net-next 1/4] net: qualcomm: rmnet: Fix casting issues

In reply to Subash Abhinov Kasiviswanathan

From: Subash Abhinov Kasiviswanathan <[email protected]>
Date: Mon, 12 Mar 2018 20:26:06 -0600

Quoted 13 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h +1 -1
index 6ce31e2..65b074e 100644
@@ -44,7 +44,7 @@ struct rmnet_map_header {
 	u8  reserved_bit:1;
 	u8  cd_bit:1;
 	u8  mux_id;
-	u16 pkt_len;
+	__be16 pkt_len;
 }  __aligned(1);
 
 struct rmnet_map_dl_csum_trailer {

...

Quoted 15 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +2 -1
index c74a6c5..4e342a3 100644
@@ -307,7 +307,8 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
 		return NULL;
 
 	maph = (struct rmnet_map_header *)skb->data;
-	packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header);
+	packet_len = ntohs((__force __be16)maph->pkt_len) +
+		     sizeof(struct rmnet_map_header);
 
 	if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4)
 		packet_len += sizeof(struct rmnet_map_dl_csum_trailer);

drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, · line 323

Quoted 8 lines
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c +1 -1
@@ -316,7 +317,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
 		return NULL;
 
 	/* Some hardware can send us empty frames. Catch them */
-	if (ntohs(maph->pkt_len) == 0)
+	if (ntohs((__force __be16)maph->pkt_len) == 0)
 		return NULL;
 
 	skbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, GFP_ATOMIC);

Ummm, if you change pkt_len to be a proper __be16, then you don't need these casts when passing it to ntohs().

#3 lore raw

Re: [PATCH net-next 1/4] net: qualcomm: rmnet: Fix casting issues

Quoted 2 lines

Ummm, if you change pkt_len to be a proper __be16, then you don't need these casts when passing it to ntohs().

Hi David

I have fixed this now in v2.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project