Make it similar to drivers like ipvlan / macvlan so it is easier to read.
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Cc: Dan Williams <dcbw@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
struct rmnet_walk_data {
struct net_device *real_dev;
struct list_head *head;
- struct rmnet_real_dev_info *real_dev_info;
+ struct rmnet_port *port;
};
static int rmnet_is_real_dev_registered(const struct net_device *real_dev)
}
/* Needs rtnl lock */
-static struct rmnet_real_dev_info*
-rmnet_get_real_dev_info_rtnl(const struct net_device *real_dev)
+static struct rmnet_port*
+rmnet_get_port_rtnl(const struct net_device *real_dev)
{
return rtnl_dereference(real_dev->rx_handler_data);
}
static struct rmnet_endpoint*
rmnet_get_endpoint(struct net_device *dev, int config_id)
{
- struct rmnet_real_dev_info *r;
struct rmnet_endpoint *ep;
+ struct rmnet_port *port;
if (!rmnet_is_real_dev_registered(dev)) {
ep = rmnet_vnd_get_endpoint(dev);
} else {
- r = rmnet_get_real_dev_info_rtnl(dev);
+ port = rmnet_get_port_rtnl(dev);
- ep = &r->muxed_ep[config_id];
+ ep = &port->muxed_ep[config_id];
}
return ep;
}
static int rmnet_unregister_real_device(struct net_device *real_dev,
- struct rmnet_real_dev_info *r)
+ struct rmnet_port *port)
{
- if (r->nr_rmnet_devs)
+ if (port->nr_rmnet_devs)
return -EINVAL;
- kfree(r);
+ kfree(port);
netdev_rx_handler_unregister(real_dev);
static int rmnet_register_real_device(struct net_device *real_dev)
{
- struct rmnet_real_dev_info *r;
+ struct rmnet_port *port;
int rc;
ASSERT_RTNL();
if (rmnet_is_real_dev_registered(real_dev))
return 0;
- r = kzalloc(sizeof(*r), GFP_ATOMIC);
- if (!r)
+ port = kzalloc(sizeof(*port), GFP_ATOMIC);
+ if (!port)
return -ENOMEM;
- r->dev = real_dev;
- rc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, r);
+ port->dev = real_dev;
+ rc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, port);
if (rc) {
- kfree(r);
+ kfree(port);
return -EBUSY;
}
RMNET_INGRESS_FORMAT_MAP;
int egress_format = RMNET_EGRESS_FORMAT_MUXING |
RMNET_EGRESS_FORMAT_MAP;
- struct rmnet_real_dev_info *r;
struct net_device *real_dev;
int mode = RMNET_EPMODE_VND;
+ struct rmnet_port *port;
int err = 0;
u16 mux_id;
if (err)
goto err0;
- r = rmnet_get_real_dev_info_rtnl(real_dev);
- err = rmnet_vnd_newlink(mux_id, dev, r, real_dev);
+ port = rmnet_get_port_rtnl(real_dev);
+ err = rmnet_vnd_newlink(mux_id, dev, port, real_dev);
if (err)
goto err1;
netdev_dbg(dev, "data format [ingress 0x%08X] [egress 0x%08X]\n",
ingress_format, egress_format);
- r->egress_data_format = egress_format;
- r->ingress_data_format = ingress_format;
+ port->egress_data_format = egress_format;
+ port->ingress_data_format = ingress_format;
rmnet_set_endpoint_config(real_dev, mux_id, mode, dev);
rmnet_set_endpoint_config(dev, mux_id, mode, real_dev);
return 0;
err2:
- rmnet_vnd_dellink(mux_id, r);
+ rmnet_vnd_dellink(mux_id, port);
err1:
- rmnet_unregister_real_device(real_dev, r);
+ rmnet_unregister_real_device(real_dev, port);
err0:
return err;
}
static void rmnet_dellink(struct net_device *dev, struct list_head *head)
{
- struct rmnet_real_dev_info *r;
struct net_device *real_dev;
+ struct rmnet_port *port;
u8 mux_id;
rcu_read_lock();
if (!real_dev || !rmnet_is_real_dev_registered(real_dev))
return;
- r = rmnet_get_real_dev_info_rtnl(real_dev);
+ port = rmnet_get_port_rtnl(real_dev);
mux_id = rmnet_vnd_get_mux(dev);
- rmnet_vnd_dellink(mux_id, r);
+ rmnet_vnd_dellink(mux_id, port);
netdev_upper_dev_unlink(dev, real_dev);
- rmnet_unregister_real_device(real_dev, r);
+ rmnet_unregister_real_device(real_dev, port);
unregister_netdevice_queue(dev, head);
}
mux_id = rmnet_vnd_get_mux(rmnet_dev);
- rmnet_vnd_dellink(mux_id, d->real_dev_info);
+ rmnet_vnd_dellink(mux_id, d->port);
netdev_upper_dev_unlink(rmnet_dev, d->real_dev);
unregister_netdevice_queue(rmnet_dev, d->head);
static void rmnet_force_unassociate_device(struct net_device *dev)
{
struct net_device *real_dev = dev;
- struct rmnet_real_dev_info *r;
struct rmnet_walk_data d;
+ struct rmnet_port *port;
LIST_HEAD(list);
if (!rmnet_is_real_dev_registered(real_dev))
d.real_dev = real_dev;
d.head = &list;
- r = rmnet_get_real_dev_info_rtnl(dev);
- d.real_dev_info = r;
+ port = rmnet_get_port_rtnl(dev);
+ d.port = port;
rcu_read_lock();
netdev_walk_all_lower_dev_rcu(real_dev, rmnet_dev_walk_unreg, &d);
rcu_read_unlock();
unregister_netdevice_many(&list);
- rmnet_unregister_real_device(real_dev, r);
+ rmnet_unregister_real_device(real_dev, port);
}
static int rmnet_config_notify_cb(struct notifier_block *nb,
};
/* Needs either rcu_read_lock() or rtnl lock */
-struct rmnet_real_dev_info*
-rmnet_get_real_dev_info(struct net_device *real_dev)
+struct rmnet_port *rmnet_get_port(struct net_device *real_dev)
{
if (rmnet_is_real_dev_registered(real_dev))
return rcu_dereference_rtnl(real_dev->rx_handler_data);
/* One instance of this structure is instantiated for each real_dev associated
* with rmnet.
*/
-struct rmnet_real_dev_info {
+struct rmnet_port {
struct net_device *dev;
struct rmnet_endpoint local_ep;
struct rmnet_endpoint muxed_ep[RMNET_MAX_LOGICAL_EP];
struct net_device *real_dev;
};
-struct rmnet_real_dev_info*
-rmnet_get_real_dev_info(struct net_device *real_dev);
+struct rmnet_port *rmnet_get_port(struct net_device *real_dev);
#endif /* _RMNET_CONFIG_H_ */
static rx_handler_result_t
rmnet_ingress_deliver_packet(struct sk_buff *skb,
- struct rmnet_real_dev_info *r)
+ struct rmnet_port *port)
{
- if (!r) {
+ if (!port) {
kfree_skb(skb);
return RX_HANDLER_CONSUMED;
}
- skb->dev = r->local_ep.egress_dev;
+ skb->dev = port->local_ep.egress_dev;
- return rmnet_deliver_skb(skb, &r->local_ep);
+ return rmnet_deliver_skb(skb, &port->local_ep);
}
/* MAP handler */
static rx_handler_result_t
__rmnet_map_ingress_handler(struct sk_buff *skb,
- struct rmnet_real_dev_info *r)
+ struct rmnet_port *port)
{
struct rmnet_endpoint *ep;
u8 mux_id;
u16 len;
if (RMNET_MAP_GET_CD_BIT(skb)) {
- if (r->ingress_data_format
+ if (port->ingress_data_format
& RMNET_INGRESS_FORMAT_MAP_COMMANDS)
- return rmnet_map_command(skb, r);
+ return rmnet_map_command(skb, port);
kfree_skb(skb);
return RX_HANDLER_CONSUMED;
return RX_HANDLER_CONSUMED;
}
- ep = &r->muxed_ep[mux_id];
+ ep = &port->muxed_ep[mux_id];
- if (r->ingress_data_format & RMNET_INGRESS_FORMAT_DEMUXING)
+ if (port->ingress_data_format & RMNET_INGRESS_FORMAT_DEMUXING)
skb->dev = ep->egress_dev;
/* Subtract MAP header */
static rx_handler_result_t
rmnet_map_ingress_handler(struct sk_buff *skb,
- struct rmnet_real_dev_info *r)
+ struct rmnet_port *port)
{
struct sk_buff *skbn;
int rc;
- if (r->ingress_data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
- while ((skbn = rmnet_map_deaggregate(skb, r)) != NULL)
- __rmnet_map_ingress_handler(skbn, r);
+ if (port->ingress_data_format & RMNET_INGRESS_FORMAT_DEAGGREGATION) {
+ while ((skbn = rmnet_map_deaggregate(skb)) != NULL)
+ __rmnet_map_ingress_handler(skbn, port);
consume_skb(skb);
rc = RX_HANDLER_CONSUMED;
} else {
- rc = __rmnet_map_ingress_handler(skb, r);
+ rc = __rmnet_map_ingress_handler(skb, port);
}
return rc;
}
static int rmnet_map_egress_handler(struct sk_buff *skb,
- struct rmnet_real_dev_info *r,
+ struct rmnet_port *port,
struct rmnet_endpoint *ep,
struct net_device *orig_dev)
{
if (!map_header)
return RMNET_MAP_CONSUMED;
- if (r->egress_data_format & RMNET_EGRESS_FORMAT_MUXING) {
+ if (port->egress_data_format & RMNET_EGRESS_FORMAT_MUXING) {
if (ep->mux_id == 0xff)
map_header->mux_id = 0;
else
*/
rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb)
{
- struct rmnet_real_dev_info *r;
+ struct rmnet_port *port;
struct sk_buff *skb = *pskb;
struct net_device *dev;
int rc;
return RX_HANDLER_CONSUMED;
dev = skb->dev;
- r = rmnet_get_real_dev_info(dev);
+ port = rmnet_get_port(dev);
- if (r->ingress_data_format & RMNET_INGRESS_FORMAT_MAP) {
- rc = rmnet_map_ingress_handler(skb, r);
+ if (port->ingress_data_format & RMNET_INGRESS_FORMAT_MAP) {
+ rc = rmnet_map_ingress_handler(skb, port);
} else {
switch (ntohs(skb->protocol)) {
case ETH_P_MAP:
- if (r->local_ep.rmnet_mode ==
+ if (port->local_ep.rmnet_mode ==
RMNET_EPMODE_BRIDGE) {
- rc = rmnet_ingress_deliver_packet(skb, r);
+ rc = rmnet_ingress_deliver_packet(skb, port);
} else {
kfree_skb(skb);
rc = RX_HANDLER_CONSUMED;
case ETH_P_IP:
case ETH_P_IPV6:
- rc = rmnet_ingress_deliver_packet(skb, r);
+ rc = rmnet_ingress_deliver_packet(skb, port);
break;
default:
void rmnet_egress_handler(struct sk_buff *skb,
struct rmnet_endpoint *ep)
{
- struct rmnet_real_dev_info *r;
struct net_device *orig_dev;
+ struct rmnet_port *port;
orig_dev = skb->dev;
skb->dev = ep->egress_dev;
- r = rmnet_get_real_dev_info(skb->dev);
- if (!r) {
+ port = rmnet_get_port(skb->dev);
+ if (!port) {
kfree_skb(skb);
return;
}
- if (r->egress_data_format & RMNET_EGRESS_FORMAT_MAP) {
- switch (rmnet_map_egress_handler(skb, r, ep, orig_dev)) {
+ if (port->egress_data_format & RMNET_EGRESS_FORMAT_MAP) {
+ switch (rmnet_map_egress_handler(skb, port, ep, orig_dev)) {
case RMNET_MAP_CONSUMED:
return;
#define RMNET_MAP_ADD_PAD_BYTES 1
u8 rmnet_map_demultiplex(struct sk_buff *skb);
-struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
- struct rmnet_real_dev_info *rdinfo);
-
+struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb);
struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb,
int hdrlen, int pad);
rx_handler_result_t rmnet_map_command(struct sk_buff *skb,
- struct rmnet_real_dev_info *rdinfo);
+ struct rmnet_port *port);
#endif /* _RMNET_MAP_H_ */
#include "rmnet_vnd.h"
static u8 rmnet_map_do_flow_control(struct sk_buff *skb,
- struct rmnet_real_dev_info *rdinfo,
+ struct rmnet_port *rdinfo,
int enable)
{
struct rmnet_map_control_command *cmd;
}
static void rmnet_map_send_ack(struct sk_buff *skb,
- unsigned char type,
- struct rmnet_real_dev_info *rdinfo)
+ unsigned char type)
{
struct rmnet_map_control_command *cmd;
int xmit_status;
* name is decoded here and appropriate handler is called.
*/
rx_handler_result_t rmnet_map_command(struct sk_buff *skb,
- struct rmnet_real_dev_info *rdinfo)
+ struct rmnet_port *port)
{
struct rmnet_map_control_command *cmd;
unsigned char command_name;
switch (command_name) {
case RMNET_MAP_COMMAND_FLOW_ENABLE:
- rc = rmnet_map_do_flow_control(skb, rdinfo, 1);
+ rc = rmnet_map_do_flow_control(skb, port, 1);
break;
case RMNET_MAP_COMMAND_FLOW_DISABLE:
- rc = rmnet_map_do_flow_control(skb, rdinfo, 0);
+ rc = rmnet_map_do_flow_control(skb, port, 0);
break;
default:
break;
}
if (rc == RMNET_MAP_COMMAND_ACK)
- rmnet_map_send_ack(skb, rc, rdinfo);
+ rmnet_map_send_ack(skb, rc);
return RX_HANDLER_CONSUMED;
}
* returned, indicating that there are no more packets to deaggregate. Caller
* is responsible for freeing the original skb.
*/
-struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb,
- struct rmnet_real_dev_info *rdinfo)
+struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb)
{
struct rmnet_map_header *maph;
struct sk_buff *skbn;
/* Exposed API */
int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
- struct rmnet_real_dev_info *r,
+ struct rmnet_port *port,
struct net_device *real_dev)
{
struct rmnet_priv *priv;
int rc;
- if (r->rmnet_devices[id])
+ if (port->rmnet_devices[id])
return -EINVAL;
rc = register_netdevice(rmnet_dev);
if (!rc) {
- r->rmnet_devices[id] = rmnet_dev;
- r->nr_rmnet_devs++;
+ port->rmnet_devices[id] = rmnet_dev;
+ port->nr_rmnet_devs++;
+
rmnet_dev->rtnl_link_ops = &rmnet_link_ops;
priv = netdev_priv(rmnet_dev);
return rc;
}
-int rmnet_vnd_dellink(u8 id, struct rmnet_real_dev_info *r)
+int rmnet_vnd_dellink(u8 id, struct rmnet_port *port)
{
- if (id >= RMNET_MAX_LOGICAL_EP || !r->rmnet_devices[id])
+ if (id >= RMNET_MAX_LOGICAL_EP || !port->rmnet_devices[id])
return -EINVAL;
- r->rmnet_devices[id] = NULL;
- r->nr_rmnet_devs--;
+ port->rmnet_devices[id] = NULL;
+ port->nr_rmnet_devs--;
return 0;
}
int rmnet_vnd_do_flow_control(struct net_device *dev, int enable);
struct rmnet_endpoint *rmnet_vnd_get_endpoint(struct net_device *dev);
int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
- struct rmnet_real_dev_info *r,
+ struct rmnet_port *port,
struct net_device *real_dev);
-int rmnet_vnd_dellink(u8 id, struct rmnet_real_dev_info *r);
+int rmnet_vnd_dellink(u8 id, struct rmnet_port *port);
void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev);
u8 rmnet_vnd_get_mux(struct net_device *rmnet_dev);