mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-01 07:26:39 +07:00
Merge branch 'hv_netvsc-cleanups'
Vitaly Kuznetsov says: ==================== hv_netvsc: cleanup after untangling the pointer mess Changes since v1: - resend when net-next is open [David Miller] - rebased to current net-next. After we made traveling through our internal structures explicit it became obvious that some functions take arguments they don't need just to do redundant pointer travel and get to what they really need while their callers already have the required information. This is just a cleanup series with no functional changes intended. It doesn't pretend to be complete, additional cleanup of other functions may follow. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
b94eb2ce3b
@ -173,6 +173,7 @@ struct rndis_device {
|
||||
|
||||
/* Interface */
|
||||
struct rndis_message;
|
||||
struct netvsc_device;
|
||||
int netvsc_device_add(struct hv_device *device, void *additional_info);
|
||||
int netvsc_device_remove(struct hv_device *device);
|
||||
int netvsc_send(struct hv_device *device,
|
||||
@ -189,8 +190,8 @@ int netvsc_recv_callback(struct hv_device *device_obj,
|
||||
struct vmbus_channel *channel,
|
||||
u16 vlan_tci);
|
||||
void netvsc_channel_cb(void *context);
|
||||
int rndis_filter_open(struct hv_device *dev);
|
||||
int rndis_filter_close(struct hv_device *dev);
|
||||
int rndis_filter_open(struct netvsc_device *nvdev);
|
||||
int rndis_filter_close(struct netvsc_device *nvdev);
|
||||
int rndis_filter_device_add(struct hv_device *dev,
|
||||
void *additional_info);
|
||||
void rndis_filter_device_remove(struct hv_device *dev);
|
||||
@ -200,7 +201,7 @@ int rndis_filter_receive(struct hv_device *dev,
|
||||
struct vmbus_channel *channel);
|
||||
|
||||
int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
|
||||
int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
|
||||
int rndis_filter_set_device_mac(struct net_device *ndev, char *mac);
|
||||
|
||||
void netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
|
||||
|
||||
@ -743,6 +744,18 @@ struct netvsc_device {
|
||||
atomic_t vf_use_cnt;
|
||||
};
|
||||
|
||||
static inline struct netvsc_device *
|
||||
net_device_to_netvsc_device(struct net_device *ndev)
|
||||
{
|
||||
return ((struct net_device_context *)netdev_priv(ndev))->nvdev;
|
||||
}
|
||||
|
||||
static inline struct netvsc_device *
|
||||
hv_device_to_netvsc_device(struct hv_device *device)
|
||||
{
|
||||
return net_device_to_netvsc_device(hv_get_drvdata(device));
|
||||
}
|
||||
|
||||
/* NdisInitialize message */
|
||||
struct rndis_initialize_request {
|
||||
u32 req_id;
|
||||
|
@ -95,9 +95,7 @@ static void free_netvsc_device(struct netvsc_device *nvdev)
|
||||
|
||||
static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(device);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *net_device = net_device_ctx->nvdev;
|
||||
struct netvsc_device *net_device = hv_device_to_netvsc_device(device);
|
||||
|
||||
if (net_device && net_device->destroy)
|
||||
net_device = NULL;
|
||||
@ -107,9 +105,7 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
|
||||
|
||||
static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(device);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *net_device = net_device_ctx->nvdev;
|
||||
struct netvsc_device *net_device = hv_device_to_netvsc_device(device);
|
||||
|
||||
if (!net_device)
|
||||
goto get_in_err;
|
||||
@ -128,8 +124,7 @@ static int netvsc_destroy_buf(struct hv_device *device)
|
||||
struct nvsp_message *revoke_packet;
|
||||
int ret = 0;
|
||||
struct net_device *ndev = hv_get_drvdata(device);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *net_device = net_device_ctx->nvdev;
|
||||
struct netvsc_device *net_device = net_device_to_netvsc_device(ndev);
|
||||
|
||||
/*
|
||||
* If we got a section count, it means we received a
|
||||
|
@ -98,16 +98,14 @@ static void netvsc_set_multicast_list(struct net_device *net)
|
||||
|
||||
static int netvsc_open(struct net_device *net)
|
||||
{
|
||||
struct net_device_context *net_device_ctx = netdev_priv(net);
|
||||
struct hv_device *device_obj = net_device_ctx->device_ctx;
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *nvdev = net_device_to_netvsc_device(net);
|
||||
struct rndis_device *rdev;
|
||||
int ret = 0;
|
||||
|
||||
netif_carrier_off(net);
|
||||
|
||||
/* Open up the device */
|
||||
ret = rndis_filter_open(device_obj);
|
||||
ret = rndis_filter_open(nvdev);
|
||||
if (ret != 0) {
|
||||
netdev_err(net, "unable to open device (ret %d).\n", ret);
|
||||
return ret;
|
||||
@ -125,7 +123,6 @@ static int netvsc_open(struct net_device *net)
|
||||
static int netvsc_close(struct net_device *net)
|
||||
{
|
||||
struct net_device_context *net_device_ctx = netdev_priv(net);
|
||||
struct hv_device *device_obj = net_device_ctx->device_ctx;
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
int ret;
|
||||
u32 aread, awrite, i, msec = 10, retry = 0, retry_max = 20;
|
||||
@ -135,7 +132,7 @@ static int netvsc_close(struct net_device *net)
|
||||
|
||||
/* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
|
||||
cancel_work_sync(&net_device_ctx->work);
|
||||
ret = rndis_filter_close(device_obj);
|
||||
ret = rndis_filter_close(nvdev);
|
||||
if (ret != 0) {
|
||||
netdev_err(net, "unable to close device (ret %d).\n", ret);
|
||||
return ret;
|
||||
@ -701,7 +698,6 @@ int netvsc_recv_callback(struct hv_device *device_obj,
|
||||
}
|
||||
|
||||
vf_injection_done:
|
||||
net_device_ctx = netdev_priv(net);
|
||||
rx_stats = this_cpu_ptr(net_device_ctx->rx_stats);
|
||||
|
||||
/* Allocate a skb - TODO direct I/O to pages? */
|
||||
@ -986,8 +982,6 @@ static struct rtnl_link_stats64 *netvsc_get_stats64(struct net_device *net,
|
||||
|
||||
static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
|
||||
{
|
||||
struct net_device_context *ndevctx = netdev_priv(ndev);
|
||||
struct hv_device *hdev = ndevctx->device_ctx;
|
||||
struct sockaddr *addr = p;
|
||||
char save_adr[ETH_ALEN];
|
||||
unsigned char save_aatype;
|
||||
@ -1000,7 +994,7 @@ static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
|
||||
if (err != 0)
|
||||
return err;
|
||||
|
||||
err = rndis_filter_set_device_mac(hdev, addr->sa_data);
|
||||
err = rndis_filter_set_device_mac(ndev, addr->sa_data);
|
||||
if (err != 0) {
|
||||
/* roll back to saved MAC */
|
||||
memcpy(ndev->dev_addr, save_adr, ETH_ALEN);
|
||||
@ -1248,7 +1242,7 @@ static int netvsc_vf_up(struct net_device *vf_netdev)
|
||||
/*
|
||||
* Open the device before switching data path.
|
||||
*/
|
||||
rndis_filter_open(net_device_ctx->device_ctx);
|
||||
rndis_filter_open(netvsc_dev);
|
||||
|
||||
/*
|
||||
* notify the host to switch the data path.
|
||||
@ -1303,7 +1297,7 @@ static int netvsc_vf_down(struct net_device *vf_netdev)
|
||||
udelay(50);
|
||||
netvsc_switch_datapath(ndev, false);
|
||||
netdev_info(ndev, "Data path switched from VF: %s\n", vf_netdev->name);
|
||||
rndis_filter_close(net_device_ctx->device_ctx);
|
||||
rndis_filter_close(netvsc_dev);
|
||||
netif_carrier_on(ndev);
|
||||
/*
|
||||
* Notify peers.
|
||||
|
@ -543,11 +543,9 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev)
|
||||
#define NWADR_STR "NetworkAddress"
|
||||
#define NWADR_STRLEN 14
|
||||
|
||||
int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
|
||||
int rndis_filter_set_device_mac(struct net_device *ndev, char *mac)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(hdev);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *nvdev = net_device_to_netvsc_device(ndev);
|
||||
struct rndis_device *rdev = nvdev->extension;
|
||||
struct rndis_request *request;
|
||||
struct rndis_set_request *set;
|
||||
@ -622,12 +620,10 @@ int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
|
||||
}
|
||||
|
||||
static int
|
||||
rndis_filter_set_offload_params(struct hv_device *hdev,
|
||||
rndis_filter_set_offload_params(struct net_device *ndev,
|
||||
struct ndis_offload_params *req_offloads)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(hdev);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *nvdev = net_device_to_netvsc_device(ndev);
|
||||
struct rndis_device *rdev = nvdev->extension;
|
||||
struct rndis_request *request;
|
||||
struct rndis_set_request *set;
|
||||
@ -851,8 +847,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
|
||||
u32 status;
|
||||
int ret;
|
||||
unsigned long t;
|
||||
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *nvdev = net_device_to_netvsc_device(dev->ndev);
|
||||
|
||||
request = get_rndis_request(dev, RNDIS_MSG_INIT,
|
||||
RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
|
||||
@ -977,8 +972,7 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
|
||||
{
|
||||
struct net_device *ndev =
|
||||
hv_get_drvdata(new_sc->primary_channel->device_obj);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *nvscdev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *nvscdev = net_device_to_netvsc_device(ndev);
|
||||
u16 chn_index = new_sc->offermsg.offer.sub_channel_index;
|
||||
int ret;
|
||||
unsigned long flags;
|
||||
@ -1088,7 +1082,7 @@ int rndis_filter_device_add(struct hv_device *dev,
|
||||
offloads.lso_v2_ipv4 = NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED;
|
||||
|
||||
|
||||
ret = rndis_filter_set_offload_params(dev, &offloads);
|
||||
ret = rndis_filter_set_offload_params(net, &offloads);
|
||||
if (ret)
|
||||
goto err_dev_remv;
|
||||
|
||||
@ -1196,9 +1190,7 @@ int rndis_filter_device_add(struct hv_device *dev,
|
||||
|
||||
void rndis_filter_device_remove(struct hv_device *dev)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(dev);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *net_dev = net_device_ctx->nvdev;
|
||||
struct netvsc_device *net_dev = hv_device_to_netvsc_device(dev);
|
||||
struct rndis_device *rndis_dev = net_dev->extension;
|
||||
unsigned long t;
|
||||
|
||||
@ -1222,27 +1214,19 @@ void rndis_filter_device_remove(struct hv_device *dev)
|
||||
}
|
||||
|
||||
|
||||
int rndis_filter_open(struct hv_device *dev)
|
||||
int rndis_filter_open(struct netvsc_device *nvdev)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(dev);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *net_device = net_device_ctx->nvdev;
|
||||
|
||||
if (!net_device)
|
||||
if (!nvdev)
|
||||
return -EINVAL;
|
||||
|
||||
if (atomic_inc_return(&net_device->open_cnt) != 1)
|
||||
if (atomic_inc_return(&nvdev->open_cnt) != 1)
|
||||
return 0;
|
||||
|
||||
return rndis_filter_open_device(net_device->extension);
|
||||
return rndis_filter_open_device(nvdev->extension);
|
||||
}
|
||||
|
||||
int rndis_filter_close(struct hv_device *dev)
|
||||
int rndis_filter_close(struct netvsc_device *nvdev)
|
||||
{
|
||||
struct net_device *ndev = hv_get_drvdata(dev);
|
||||
struct net_device_context *net_device_ctx = netdev_priv(ndev);
|
||||
struct netvsc_device *nvdev = net_device_ctx->nvdev;
|
||||
|
||||
if (!nvdev)
|
||||
return -EINVAL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user