Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'rmnet-next'

Subash Abhinov Kasiviswanathan says:

====================
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 new rmnet netlink attributes in uapi and updates the usage.
Patch 5 has the implementation of the fill_info operation.

v1->v2: Remove the force casts since the data type is changed to __be
types as mentioned by David.
v2->v3: Update copyright in files which actually had changes as
mentioned by Joe.
v3->v4: Add new netlink attributes for mux_id and flags instead of using the
the vlan attributes as mentioned by David. The rmnet specific flags are also
moved to uapi. The netlink updates are done as part of #4 and #5 has the
fill_info operation.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+94 -41
+56 -17
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 42 42 */ 43 43 44 44 /* Local Definitions and Declarations */ 45 + 46 + static const struct nla_policy rmnet_policy[IFLA_RMNET_MAX + 1] = { 47 + [IFLA_RMNET_MUX_ID] = { .type = NLA_U16 }, 48 + [IFLA_RMNET_FLAGS] = { .len = sizeof(struct ifla_rmnet_flags) }, 49 + }; 45 50 46 51 static int rmnet_is_real_dev_registered(const struct net_device *real_dev) 47 52 { ··· 136 131 struct nlattr *tb[], struct nlattr *data[], 137 132 struct netlink_ext_ack *extack) 138 133 { 139 - u32 data_format = RMNET_INGRESS_FORMAT_DEAGGREGATION; 134 + u32 data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION; 140 135 struct net_device *real_dev; 141 136 int mode = RMNET_EPMODE_VND; 142 137 struct rmnet_endpoint *ep; ··· 148 143 if (!real_dev || !dev) 149 144 return -ENODEV; 150 145 151 - if (!data[IFLA_VLAN_ID]) 146 + if (!data[IFLA_RMNET_MUX_ID]) 152 147 return -EINVAL; 153 148 154 149 ep = kzalloc(sizeof(*ep), GFP_ATOMIC); 155 150 if (!ep) 156 151 return -ENOMEM; 157 152 158 - mux_id = nla_get_u16(data[IFLA_VLAN_ID]); 153 + mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]); 159 154 160 155 err = rmnet_register_real_device(real_dev); 161 156 if (err) ··· 170 165 171 166 hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]); 172 167 173 - if (data[IFLA_VLAN_FLAGS]) { 174 - struct ifla_vlan_flags *flags; 168 + if (data[IFLA_RMNET_FLAGS]) { 169 + struct ifla_rmnet_flags *flags; 175 170 176 - flags = nla_data(data[IFLA_VLAN_FLAGS]); 171 + flags = nla_data(data[IFLA_RMNET_FLAGS]); 177 172 data_format = flags->flags & flags->mask; 178 173 } 179 174 ··· 281 276 { 282 277 u16 mux_id; 283 278 284 - if (!data || !data[IFLA_VLAN_ID]) 279 + if (!data || !data[IFLA_RMNET_MUX_ID]) 285 280 return -EINVAL; 286 281 287 - mux_id = nla_get_u16(data[IFLA_VLAN_ID]); 282 + mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]); 288 283 if (mux_id > (RMNET_MAX_LOGICAL_EP - 1)) 289 284 return -ERANGE; 290 285 ··· 309 304 310 305 port = rmnet_get_port_rtnl(real_dev); 311 306 312 - if (data[IFLA_VLAN_ID]) { 313 - mux_id = nla_get_u16(data[IFLA_VLAN_ID]); 307 + if (data[IFLA_RMNET_MUX_ID]) { 308 + mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]); 314 309 ep = rmnet_get_endpoint(port, priv->mux_id); 315 310 316 311 hlist_del_init_rcu(&ep->hlnode); ··· 320 315 priv->mux_id = mux_id; 321 316 } 322 317 323 - if (data[IFLA_VLAN_FLAGS]) { 324 - struct ifla_vlan_flags *flags; 318 + if (data[IFLA_RMNET_FLAGS]) { 319 + struct ifla_rmnet_flags *flags; 325 320 326 - flags = nla_data(data[IFLA_VLAN_FLAGS]); 321 + flags = nla_data(data[IFLA_RMNET_FLAGS]); 327 322 port->data_format = flags->flags & flags->mask; 328 323 } 329 324 ··· 332 327 333 328 static size_t rmnet_get_size(const struct net_device *dev) 334 329 { 335 - return nla_total_size(2) /* IFLA_VLAN_ID */ + 336 - nla_total_size(sizeof(struct ifla_vlan_flags)); /* IFLA_VLAN_FLAGS */ 330 + return 331 + /* IFLA_RMNET_MUX_ID */ 332 + nla_total_size(2) + 333 + /* IFLA_RMNET_FLAGS */ 334 + nla_total_size(sizeof(struct ifla_rmnet_flags)); 335 + } 336 + 337 + static int rmnet_fill_info(struct sk_buff *skb, const struct net_device *dev) 338 + { 339 + struct rmnet_priv *priv = netdev_priv(dev); 340 + struct net_device *real_dev; 341 + struct ifla_rmnet_flags f; 342 + struct rmnet_port *port; 343 + 344 + real_dev = priv->real_dev; 345 + 346 + if (!rmnet_is_real_dev_registered(real_dev)) 347 + return -ENODEV; 348 + 349 + if (nla_put_u16(skb, IFLA_RMNET_MUX_ID, priv->mux_id)) 350 + goto nla_put_failure; 351 + 352 + port = rmnet_get_port_rtnl(real_dev); 353 + 354 + f.flags = port->data_format; 355 + f.mask = ~0; 356 + 357 + if (nla_put(skb, IFLA_RMNET_FLAGS, sizeof(f), &f)) 358 + goto nla_put_failure; 359 + 360 + return 0; 361 + 362 + nla_put_failure: 363 + return -EMSGSIZE; 337 364 } 338 365 339 366 struct rtnl_link_ops rmnet_link_ops __read_mostly = { 340 367 .kind = "rmnet", 341 - .maxtype = __IFLA_VLAN_MAX, 368 + .maxtype = __IFLA_RMNET_MAX, 342 369 .priv_size = sizeof(struct rmnet_priv), 343 370 .setup = rmnet_vnd_setup, 344 371 .validate = rmnet_rtnl_validate, ··· 378 341 .dellink = rmnet_dellink, 379 342 .get_size = rmnet_get_size, 380 343 .changelink = rmnet_changelink, 344 + .policy = rmnet_policy, 345 + .fill_info = rmnet_fill_info, 381 346 }; 382 347 383 348 /* Needs either rcu_read_lock() or rtnl lock */
+1 -1
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
··· 1 - /* Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2014, 2016-2018 The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and
+6 -6
drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 70 70 u8 mux_id; 71 71 72 72 if (RMNET_MAP_GET_CD_BIT(skb)) { 73 - if (port->data_format & RMNET_INGRESS_FORMAT_MAP_COMMANDS) 73 + if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) 74 74 return rmnet_map_command(skb, port); 75 75 76 76 goto free_skb; ··· 93 93 skb_pull(skb, sizeof(struct rmnet_map_header)); 94 94 rmnet_set_skb_proto(skb); 95 95 96 - if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) { 96 + if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { 97 97 if (!rmnet_map_checksum_downlink_packet(skb, len + pad)) 98 98 skb->ip_summed = CHECKSUM_UNNECESSARY; 99 99 } ··· 121 121 skb_push(skb, ETH_HLEN); 122 122 } 123 123 124 - if (port->data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) { 124 + if (port->data_format & RMNET_FLAGS_INGRESS_DEAGGREGATION) { 125 125 while ((skbn = rmnet_map_deaggregate(skb, port)) != NULL) 126 126 __rmnet_map_ingress_handler(skbn, port); 127 127 ··· 141 141 additional_header_len = 0; 142 142 required_headroom = sizeof(struct rmnet_map_header); 143 143 144 - if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4) { 144 + if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) { 145 145 additional_header_len = sizeof(struct rmnet_map_ul_csum_header); 146 146 required_headroom += additional_header_len; 147 147 } ··· 151 151 goto fail; 152 152 } 153 153 154 - if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4) 154 + if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) 155 155 rmnet_map_checksum_uplink_packet(skb, orig_dev); 156 156 157 157 map_header = rmnet_map_add_map_header(skb, additional_header_len, 0);
+4 -4
drivers/net/ethernet/qualcomm/rmnet/rmnet_map.h
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 23 23 struct { 24 24 u16 ip_family:2; 25 25 u16 reserved:14; 26 - u16 flow_control_seq_num; 27 - u32 qos_id; 26 + __be16 flow_control_seq_num; 27 + __be32 qos_id; 28 28 } flow_control; 29 29 u8 data[0]; 30 30 }; ··· 44 44 u8 reserved_bit:1; 45 45 u8 cd_bit:1; 46 46 u8 mux_id; 47 - u16 pkt_len; 47 + __be16 pkt_len; 48 48 } __aligned(1); 49 49 50 50 struct rmnet_map_dl_csum_trailer {
+2 -2
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 69 69 struct rmnet_map_control_command *cmd; 70 70 int xmit_status; 71 71 72 - if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) { 72 + if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { 73 73 if (skb->len < sizeof(struct rmnet_map_header) + 74 74 RMNET_MAP_GET_LENGTH(skb) + 75 75 sizeof(struct rmnet_map_dl_csum_trailer)) {
+2 -3
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 309 309 maph = (struct rmnet_map_header *)skb->data; 310 310 packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header); 311 311 312 - if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) 312 + if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) 313 313 packet_len += sizeof(struct rmnet_map_dl_csum_trailer); 314 314 315 315 if (((int)skb->len - (int)packet_len) < 0) ··· 323 323 if (!skbn) 324 324 return NULL; 325 325 326 - skbn->dev = skb->dev; 327 326 skb_reserve(skbn, RMNET_MAP_DEAGGR_HEADROOM); 328 327 skb_put(skbn, packet_len); 329 328 memcpy(skbn->data, skb->data, packet_len);
+1 -7
drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h
··· 1 - /* Copyright (c) 2013-2014, 2016-2017 The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2014, 2016-2018 The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and ··· 17 17 #define RMNET_DFLT_PACKET_SIZE 1500 18 18 #define RMNET_NEEDED_HEADROOM 16 19 19 #define RMNET_TX_QUEUE_LEN 1000 20 - 21 - /* Constants */ 22 - #define RMNET_INGRESS_FORMAT_DEAGGREGATION BIT(0) 23 - #define RMNET_INGRESS_FORMAT_MAP_COMMANDS BIT(1) 24 - #define RMNET_INGRESS_FORMAT_MAP_CKSUMV4 BIT(2) 25 - #define RMNET_EGRESS_FORMAT_MAP_CKSUMV4 BIT(3) 26 20 27 21 /* Replace skb->dev to a virtual rmnet device and pass up the stack */ 28 22 #define RMNET_EPMODE_VND (1)
+1 -1
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
··· 1 - /* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. 1 + /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License version 2 and
+21
include/uapi/linux/if_link.h
··· 959 959 960 960 #define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1) 961 961 962 + /* rmnet section */ 963 + 964 + #define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) 965 + #define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) 966 + #define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) 967 + #define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) 968 + 969 + enum { 970 + IFLA_RMNET_UNSPEC, 971 + IFLA_RMNET_MUX_ID, 972 + IFLA_RMNET_FLAGS, 973 + __IFLA_RMNET_MAX, 974 + }; 975 + 976 + #define IFLA_RMNET_MAX (__IFLA_RMNET_MAX - 1) 977 + 978 + struct ifla_rmnet_flags { 979 + __u32 flags; 980 + __u32 mask; 981 + }; 982 + 962 983 #endif /* _UAPI_LINUX_IF_LINK_H */