Skip to content

Commit 14452ca

Browse files
Subash Abhinov Kasiviswanathandavem330
authored andcommitted
net: qualcomm: rmnet: Export mux_id and flags to netlink
Define new netlink attributes for rmnet mux_id and flags. These flags / mux_id were earlier using vlan flags / id respectively. The flag bits are also moved to uapi and are renamed with prefix RMNET_FLAG_*. Also add the rmnet policy to handle the new netlink attributes. Signed-off-by: Subash Abhinov Kasiviswanathan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 378e253 commit 14452ca

File tree

6 files changed

+53
-29
lines changed

6 files changed

+53
-29
lines changed

drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343

4444
/* Local Definitions and Declarations */
4545

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+
};
50+
4651
static int rmnet_is_real_dev_registered(const struct net_device *real_dev)
4752
{
4853
return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler;
@@ -131,7 +136,7 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
131136
struct nlattr *tb[], struct nlattr *data[],
132137
struct netlink_ext_ack *extack)
133138
{
134-
u32 data_format = RMNET_INGRESS_FORMAT_DEAGGREGATION;
139+
u32 data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION;
135140
struct net_device *real_dev;
136141
int mode = RMNET_EPMODE_VND;
137142
struct rmnet_endpoint *ep;
@@ -143,14 +148,14 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
143148
if (!real_dev || !dev)
144149
return -ENODEV;
145150

146-
if (!data[IFLA_VLAN_ID])
151+
if (!data[IFLA_RMNET_MUX_ID])
147152
return -EINVAL;
148153

149154
ep = kzalloc(sizeof(*ep), GFP_ATOMIC);
150155
if (!ep)
151156
return -ENOMEM;
152157

153-
mux_id = nla_get_u16(data[IFLA_VLAN_ID]);
158+
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
154159

155160
err = rmnet_register_real_device(real_dev);
156161
if (err)
@@ -165,10 +170,10 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
165170

166171
hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]);
167172

168-
if (data[IFLA_VLAN_FLAGS]) {
169-
struct ifla_vlan_flags *flags;
173+
if (data[IFLA_RMNET_FLAGS]) {
174+
struct ifla_rmnet_flags *flags;
170175

171-
flags = nla_data(data[IFLA_VLAN_FLAGS]);
176+
flags = nla_data(data[IFLA_RMNET_FLAGS]);
172177
data_format = flags->flags & flags->mask;
173178
}
174179

@@ -276,10 +281,10 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
276281
{
277282
u16 mux_id;
278283

279-
if (!data || !data[IFLA_VLAN_ID])
284+
if (!data || !data[IFLA_RMNET_MUX_ID])
280285
return -EINVAL;
281286

282-
mux_id = nla_get_u16(data[IFLA_VLAN_ID]);
287+
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
283288
if (mux_id > (RMNET_MAX_LOGICAL_EP - 1))
284289
return -ERANGE;
285290

@@ -304,8 +309,8 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
304309

305310
port = rmnet_get_port_rtnl(real_dev);
306311

307-
if (data[IFLA_VLAN_ID]) {
308-
mux_id = nla_get_u16(data[IFLA_VLAN_ID]);
312+
if (data[IFLA_RMNET_MUX_ID]) {
313+
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
309314
ep = rmnet_get_endpoint(port, priv->mux_id);
310315

311316
hlist_del_init_rcu(&ep->hlnode);
@@ -315,10 +320,10 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
315320
priv->mux_id = mux_id;
316321
}
317322

318-
if (data[IFLA_VLAN_FLAGS]) {
319-
struct ifla_vlan_flags *flags;
323+
if (data[IFLA_RMNET_FLAGS]) {
324+
struct ifla_rmnet_flags *flags;
320325

321-
flags = nla_data(data[IFLA_VLAN_FLAGS]);
326+
flags = nla_data(data[IFLA_RMNET_FLAGS]);
322327
port->data_format = flags->flags & flags->mask;
323328
}
324329

@@ -327,20 +332,24 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
327332

328333
static size_t rmnet_get_size(const struct net_device *dev)
329334
{
330-
return nla_total_size(2) /* IFLA_VLAN_ID */ +
331-
nla_total_size(sizeof(struct ifla_vlan_flags)); /* IFLA_VLAN_FLAGS */
335+
return
336+
/* IFLA_RMNET_MUX_ID */
337+
nla_total_size(2) +
338+
/* IFLA_RMNET_FLAGS */
339+
nla_total_size(sizeof(struct ifla_rmnet_flags));
332340
}
333341

334342
struct rtnl_link_ops rmnet_link_ops __read_mostly = {
335343
.kind = "rmnet",
336-
.maxtype = __IFLA_VLAN_MAX,
344+
.maxtype = __IFLA_RMNET_MAX,
337345
.priv_size = sizeof(struct rmnet_priv),
338346
.setup = rmnet_vnd_setup,
339347
.validate = rmnet_rtnl_validate,
340348
.newlink = rmnet_newlink,
341349
.dellink = rmnet_dellink,
342350
.get_size = rmnet_get_size,
343351
.changelink = rmnet_changelink,
352+
.policy = rmnet_policy,
344353
};
345354

346355
/* Needs either rcu_read_lock() or rtnl lock */

drivers/net/ethernet/qualcomm/rmnet/rmnet_handlers.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
7070
u8 mux_id;
7171

7272
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)
7474
return rmnet_map_command(skb, port);
7575

7676
goto free_skb;
@@ -93,7 +93,7 @@ __rmnet_map_ingress_handler(struct sk_buff *skb,
9393
skb_pull(skb, sizeof(struct rmnet_map_header));
9494
rmnet_set_skb_proto(skb);
9595

96-
if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) {
96+
if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) {
9797
if (!rmnet_map_checksum_downlink_packet(skb, len + pad))
9898
skb->ip_summed = CHECKSUM_UNNECESSARY;
9999
}
@@ -121,7 +121,7 @@ rmnet_map_ingress_handler(struct sk_buff *skb,
121121
skb_push(skb, ETH_HLEN);
122122
}
123123

124-
if (port->data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
124+
if (port->data_format & RMNET_FLAGS_INGRESS_DEAGGREGATION) {
125125
while ((skbn = rmnet_map_deaggregate(skb, port)) != NULL)
126126
__rmnet_map_ingress_handler(skbn, port);
127127

@@ -141,7 +141,7 @@ static int rmnet_map_egress_handler(struct sk_buff *skb,
141141
additional_header_len = 0;
142142
required_headroom = sizeof(struct rmnet_map_header);
143143

144-
if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4) {
144+
if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) {
145145
additional_header_len = sizeof(struct rmnet_map_ul_csum_header);
146146
required_headroom += additional_header_len;
147147
}
@@ -151,7 +151,7 @@ static int rmnet_map_egress_handler(struct sk_buff *skb,
151151
goto fail;
152152
}
153153

154-
if (port->data_format & RMNET_EGRESS_FORMAT_MAP_CKSUMV4)
154+
if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4)
155155
rmnet_map_checksum_uplink_packet(skb, orig_dev);
156156

157157
map_header = rmnet_map_add_map_header(skb, additional_header_len, 0);

drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void rmnet_map_send_ack(struct sk_buff *skb,
6969
struct rmnet_map_control_command *cmd;
7070
int xmit_status;
7171

72-
if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4) {
72+
if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) {
7373
if (skb->len < sizeof(struct rmnet_map_header) +
7474
RMNET_MAP_GET_LENGTH(skb) +
7575
sizeof(struct rmnet_map_dl_csum_trailer)) {

drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
309309
maph = (struct rmnet_map_header *)skb->data;
310310
packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header);
311311

312-
if (port->data_format & RMNET_INGRESS_FORMAT_MAP_CKSUMV4)
312+
if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4)
313313
packet_len += sizeof(struct rmnet_map_dl_csum_trailer);
314314

315315
if (((int)skb->len - (int)packet_len) < 0)

drivers/net/ethernet/qualcomm/rmnet/rmnet_private.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#define RMNET_NEEDED_HEADROOM 16
1919
#define RMNET_TX_QUEUE_LEN 1000
2020

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-
2721
/* Replace skb->dev to a virtual rmnet device and pass up the stack */
2822
#define RMNET_EPMODE_VND (1)
2923
/* Pass the frame directly to another device with dev_queue_xmit() */

include/uapi/linux/if_link.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,4 +959,25 @@ enum {
959959

960960
#define IFLA_TUN_MAX (__IFLA_TUN_MAX - 1)
961961

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+
962983
#endif /* _UAPI_LINUX_IF_LINK_H */

0 commit comments

Comments
 (0)