Commit 0ef2d5af authored by Mitch Williams's avatar Mitch Williams Committed by Jeff Kirsher

i40e: KISS the client interface

(KISS is Keep It Simple, Stupid. Or is it?)

The client interface vastly overengineered for what it needs to do.
It was originally designed to support multiple clients on multiple
netdevs, possibly even with multiple drivers. None of this happened,
and now we know that there will only ever be one client for i40e
(i40iw) and one for i40evf (i40iwvf). So, time for some KISS. Since
i40e and i40evf are a Dynasty, we'll simplify this one to match the
VF interface.

First, be a Destroyer and remove all of the lists and locks required
to support multiple clients. Keep one static around to keep track of
one client, and track the client instances for each netdev in the
driver's pf (or adapter) struct. Now it's Almost Human.

Since we already know the client type is iWarp, get rid of any checks
for this. Same for VSI type - it's always going to be the same type,
so it's just a Parasite.

While we're at it, fix up some comments. This makes the function
headers actually match the functions.

These changes reduce code complexity, simplify maintenance,
squash some lurking timing bugs, and allow us to Rock and Roll All
Nite.

Change-ID: I1ea79948ad73b8685272451440a34507f9a9012e
Signed-off-by: default avatarMitch Williams <mitch.a.williams@intel.com>
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent ed0e894d
...@@ -348,8 +348,10 @@ struct i40e_pf { ...@@ -348,8 +348,10 @@ struct i40e_pf {
#define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(51) #define I40E_FLAG_TRUE_PROMISC_SUPPORT BIT_ULL(51)
#define I40E_FLAG_HAVE_CRT_RETIMER BIT_ULL(52) #define I40E_FLAG_HAVE_CRT_RETIMER BIT_ULL(52)
#define I40E_FLAG_PTP_L4_CAPABLE BIT_ULL(53) #define I40E_FLAG_PTP_L4_CAPABLE BIT_ULL(53)
#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(54) #define I40E_FLAG_CLIENT_RESET BIT_ULL(54)
#define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(55) #define I40E_FLAG_TEMP_LINK_POLLING BIT_ULL(55)
#define I40E_FLAG_CLIENT_L2_CHANGE BIT_ULL(56)
#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE BIT_ULL(57)
/* tracks features that get auto disabled by errors */ /* tracks features that get auto disabled by errors */
u64 auto_disable_flags; u64 auto_disable_flags;
...@@ -358,6 +360,7 @@ struct i40e_pf { ...@@ -358,6 +360,7 @@ struct i40e_pf {
struct i40e_fcoe fcoe; struct i40e_fcoe fcoe;
#endif /* I40E_FCOE */ #endif /* I40E_FCOE */
struct i40e_client_instance *cinst;
bool stat_offsets_loaded; bool stat_offsets_loaded;
struct i40e_hw_port_stats stats; struct i40e_hw_port_stats stats;
struct i40e_hw_port_stats stats_offsets; struct i40e_hw_port_stats stats_offsets;
...@@ -813,8 +816,7 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi); ...@@ -813,8 +816,7 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi);
void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset); void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset);
void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs); void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs);
void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id); void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id);
int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id, int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id);
enum i40e_client_type type);
/** /**
* i40e_irq_dynamic_enable - Enable default interrupt generation settings * i40e_irq_dynamic_enable - Enable default interrupt generation settings
* @vsi: pointer to a vsi * @vsi: pointer to a vsi
......
...@@ -32,16 +32,10 @@ ...@@ -32,16 +32,10 @@
#include "i40e_client.h" #include "i40e_client.h"
static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR; static const char i40e_client_interface_version_str[] = I40E_CLIENT_VERSION_STR;
static struct i40e_client *registered_client;
static LIST_HEAD(i40e_devices); static LIST_HEAD(i40e_devices);
static DEFINE_MUTEX(i40e_device_mutex); static DEFINE_MUTEX(i40e_device_mutex);
static LIST_HEAD(i40e_clients);
static DEFINE_MUTEX(i40e_client_mutex);
static LIST_HEAD(i40e_client_instances);
static DEFINE_MUTEX(i40e_client_instance_mutex);
static int i40e_client_virtchnl_send(struct i40e_info *ldev, static int i40e_client_virtchnl_send(struct i40e_info *ldev,
struct i40e_client *client, struct i40e_client *client,
u32 vf_id, u8 *msg, u16 len); u32 vf_id, u8 *msg, u16 len);
...@@ -66,28 +60,6 @@ static struct i40e_ops i40e_lan_ops = { ...@@ -66,28 +60,6 @@ static struct i40e_ops i40e_lan_ops = {
.update_vsi_ctxt = i40e_client_update_vsi_ctxt, .update_vsi_ctxt = i40e_client_update_vsi_ctxt,
}; };
/**
* i40e_client_type_to_vsi_type - convert client type to vsi type
* @client_type: the i40e_client type
*
* returns the related vsi type value
**/
static
enum i40e_vsi_type i40e_client_type_to_vsi_type(enum i40e_client_type type)
{
switch (type) {
case I40E_CLIENT_IWARP:
return I40E_VSI_IWARP;
case I40E_CLIENT_VMDQ2:
return I40E_VSI_VMDQ2;
default:
pr_err("i40e: Client type unknown\n");
return I40E_VSI_TYPE_UNKNOWN;
}
}
/** /**
* i40e_client_get_params - Get the params that can change at runtime * i40e_client_get_params - Get the params that can change at runtime
* @vsi: the VSI with the message * @vsi: the VSI with the message
...@@ -134,31 +106,22 @@ int i40e_client_get_params(struct i40e_vsi *vsi, struct i40e_params *params) ...@@ -134,31 +106,22 @@ int i40e_client_get_params(struct i40e_vsi *vsi, struct i40e_params *params)
void void
i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len) i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
{ {
struct i40e_client_instance *cdev; struct i40e_pf *pf = vsi->back;
struct i40e_client_instance *cdev = pf->cinst;
if (!vsi) if (!cdev || !cdev->client)
return; return;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->virtchnl_receive) {
list_for_each_entry(cdev, &i40e_client_instances, list) { dev_dbg(&pf->pdev->dev,
if (cdev->lan_info.pf == vsi->back) {
if (!cdev->client ||
!cdev->client->ops ||
!cdev->client->ops->virtchnl_receive) {
dev_dbg(&vsi->back->pdev->dev,
"Cannot locate client instance virtual channel receive routine\n"); "Cannot locate client instance virtual channel receive routine\n");
continue; return;
} }
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
&cdev->state)) { dev_dbg(&pf->pdev->dev, "Client is not open, abort virtchnl_receive\n");
dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort virtchnl_receive\n"); return;
continue;
} }
cdev->client->ops->virtchnl_receive(&cdev->lan_info, cdev->client->ops->virtchnl_receive(&cdev->lan_info, cdev->client,
cdev->client,
vf_id, msg, len); vf_id, msg, len);
}
}
mutex_unlock(&i40e_client_instance_mutex);
} }
/** /**
...@@ -169,39 +132,28 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len) ...@@ -169,39 +132,28 @@ i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id, u8 *msg, u16 len)
**/ **/
void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi) void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
{ {
struct i40e_client_instance *cdev; struct i40e_pf *pf = vsi->back;
struct i40e_client_instance *cdev = pf->cinst;
struct i40e_params params; struct i40e_params params;
if (!vsi) if (!cdev || !cdev->client)
return; return;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->l2_param_change) {
list_for_each_entry(cdev, &i40e_client_instances, list) {
if (cdev->lan_info.pf == vsi->back) {
if (!cdev->client ||
!cdev->client->ops ||
!cdev->client->ops->l2_param_change) {
dev_dbg(&vsi->back->pdev->dev, dev_dbg(&vsi->back->pdev->dev,
"Cannot locate client instance l2_param_change routine\n"); "Cannot locate client instance l2_param_change routine\n");
continue; return;
} }
memset(&params, 0, sizeof(params)); if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
i40e_client_get_params(vsi, &params);
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state)) {
dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n"); dev_dbg(&vsi->back->pdev->dev, "Client is not open, abort l2 param change\n");
continue; return;
} }
cdev->lan_info.params = params; memcpy(&cdev->lan_info.params, &params, sizeof(struct i40e_params));
cdev->client->ops->l2_param_change(&cdev->lan_info, cdev->client->ops->l2_param_change(&cdev->lan_info, cdev->client,
cdev->client,
&params); &params);
}
}
mutex_unlock(&i40e_client_instance_mutex);
} }
/** /**
* i40e_client_release_qvlist * i40e_client_release_qvlist - release MSI-X vector mapping for client
* @ldev: pointer to L2 context. * @ldev: pointer to L2 context.
* *
**/ **/
...@@ -237,26 +189,19 @@ static void i40e_client_release_qvlist(struct i40e_info *ldev) ...@@ -237,26 +189,19 @@ static void i40e_client_release_qvlist(struct i40e_info *ldev)
**/ **/
void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset) void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
{ {
struct i40e_client_instance *cdev; struct i40e_pf *pf = vsi->back;
struct i40e_client_instance *cdev = pf->cinst;
if (!vsi) if (!cdev || !cdev->client)
return; return;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->close) {
list_for_each_entry(cdev, &i40e_client_instances, list) {
if (cdev->lan_info.netdev == vsi->netdev) {
if (!cdev->client ||
!cdev->client->ops || !cdev->client->ops->close) {
dev_dbg(&vsi->back->pdev->dev, dev_dbg(&vsi->back->pdev->dev,
"Cannot locate client instance close routine\n"); "Cannot locate client instance close routine\n");
continue; return;
} }
cdev->client->ops->close(&cdev->lan_info, cdev->client, cdev->client->ops->close(&cdev->lan_info, cdev->client, reset);
reset);
clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state); clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
i40e_client_release_qvlist(&cdev->lan_info); i40e_client_release_qvlist(&cdev->lan_info);
}
}
mutex_unlock(&i40e_client_instance_mutex);
} }
/** /**
...@@ -268,30 +213,20 @@ void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset) ...@@ -268,30 +213,20 @@ void i40e_notify_client_of_netdev_close(struct i40e_vsi *vsi, bool reset)
**/ **/
void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id) void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id)
{ {
struct i40e_client_instance *cdev; struct i40e_client_instance *cdev = pf->cinst;
if (!pf) if (!cdev || !cdev->client)
return; return;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->vf_reset) {
list_for_each_entry(cdev, &i40e_client_instances, list) {
if (cdev->lan_info.pf == pf) {
if (!cdev->client ||
!cdev->client->ops ||
!cdev->client->ops->vf_reset) {
dev_dbg(&pf->pdev->dev, dev_dbg(&pf->pdev->dev,
"Cannot locate client instance VF reset routine\n"); "Cannot locate client instance VF reset routine\n");
continue; return;
} }
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
&cdev->state)) {
dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-reset\n"); dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-reset\n");
continue; return;
}
cdev->client->ops->vf_reset(&cdev->lan_info,
cdev->client, vf_id);
}
} }
mutex_unlock(&i40e_client_instance_mutex); cdev->client->ops->vf_reset(&cdev->lan_info, cdev->client, vf_id);
} }
/** /**
...@@ -303,30 +238,21 @@ void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id) ...@@ -303,30 +238,21 @@ void i40e_notify_client_of_vf_reset(struct i40e_pf *pf, u32 vf_id)
**/ **/
void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs) void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs)
{ {
struct i40e_client_instance *cdev; struct i40e_client_instance *cdev = pf->cinst;
if (!pf) if (!cdev || !cdev->client)
return; return;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->vf_enable) {
list_for_each_entry(cdev, &i40e_client_instances, list) {
if (cdev->lan_info.pf == pf) {
if (!cdev->client ||
!cdev->client->ops ||
!cdev->client->ops->vf_enable) {
dev_dbg(&pf->pdev->dev, dev_dbg(&pf->pdev->dev,
"Cannot locate client instance VF enable routine\n"); "Cannot locate client instance VF enable routine\n");
continue; return;
} }
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state)) { &cdev->state)) {
dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-enable\n"); dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-enable\n");
continue; return;
}
cdev->client->ops->vf_enable(&cdev->lan_info,
cdev->client, num_vfs);
}
} }
mutex_unlock(&i40e_client_instance_mutex); cdev->client->ops->vf_enable(&cdev->lan_info, cdev->client, num_vfs);
} }
/** /**
...@@ -337,37 +263,25 @@ void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs) ...@@ -337,37 +263,25 @@ void i40e_notify_client_of_vf_enable(struct i40e_pf *pf, u32 num_vfs)
* If there is a client of the specified type attached to this PF, call * If there is a client of the specified type attached to this PF, call
* its vf_capable routine * its vf_capable routine
**/ **/
int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id, int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id)
enum i40e_client_type type)
{ {
struct i40e_client_instance *cdev; struct i40e_client_instance *cdev = pf->cinst;
int capable = false; int capable = false;
if (!pf) if (!cdev || !cdev->client)
return false; goto out;
mutex_lock(&i40e_client_instance_mutex); if (!cdev->client->ops || !cdev->client->ops->vf_capable) {
list_for_each_entry(cdev, &i40e_client_instances, list) { dev_info(&pf->pdev->dev,
if (cdev->lan_info.pf == pf) {
if (!cdev->client ||
!cdev->client->ops ||
!cdev->client->ops->vf_capable ||
!(cdev->client->type == type)) {
dev_dbg(&pf->pdev->dev,
"Cannot locate client instance VF capability routine\n"); "Cannot locate client instance VF capability routine\n");
continue; goto out;
}
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state)) {
dev_dbg(&pf->pdev->dev, "Client is not open, abort vf-capable\n");
continue;
} }
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state))
goto out;
capable = cdev->client->ops->vf_capable(&cdev->lan_info, capable = cdev->client->ops->vf_capable(&cdev->lan_info,
cdev->client, cdev->client,
vf_id); vf_id);
break; out:
}
}
mutex_unlock(&i40e_client_instance_mutex);
return capable; return capable;
} }
...@@ -377,27 +291,19 @@ int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id, ...@@ -377,27 +291,19 @@ int i40e_vf_client_capable(struct i40e_pf *pf, u32 vf_id,
* @client: pointer to a client struct in the client list. * @client: pointer to a client struct in the client list.
* @existing: if there was already an existing instance * @existing: if there was already an existing instance
* *
* Returns cdev ptr on success or if already exists, NULL on failure
**/ **/
static static void i40e_client_add_instance(struct i40e_pf *pf)
struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
struct i40e_client *client,
bool *existing)
{ {
struct i40e_client_instance *cdev; struct i40e_client_instance *cdev = NULL;
struct netdev_hw_addr *mac = NULL; struct netdev_hw_addr *mac = NULL;
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
mutex_lock(&i40e_client_instance_mutex); if (!registered_client || pf->cinst)
list_for_each_entry(cdev, &i40e_client_instances, list) { return;
if ((cdev->lan_info.pf == pf) && (cdev->client == client)) {
*existing = true;
goto out;
}
}
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
if (!cdev) if (!cdev)
goto out; return;
cdev->lan_info.pf = (void *)pf; cdev->lan_info.pf = (void *)pf;
cdev->lan_info.netdev = vsi->netdev; cdev->lan_info.netdev = vsi->netdev;
...@@ -417,7 +323,7 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, ...@@ -417,7 +323,7 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
if (i40e_client_get_params(vsi, &cdev->lan_info.params)) { if (i40e_client_get_params(vsi, &cdev->lan_info.params)) {
kfree(cdev); kfree(cdev);
cdev = NULL; cdev = NULL;
goto out; return;
} }
cdev->lan_info.msix_count = pf->num_iwarp_msix; cdev->lan_info.msix_count = pf->num_iwarp_msix;
...@@ -430,41 +336,20 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, ...@@ -430,41 +336,20 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
else else
dev_err(&pf->pdev->dev, "MAC address list is empty!\n"); dev_err(&pf->pdev->dev, "MAC address list is empty!\n");
cdev->client = client; cdev->client = registered_client;
INIT_LIST_HEAD(&cdev->list); pf->cinst = cdev;
list_add(&cdev->list, &i40e_client_instances);
out:
mutex_unlock(&i40e_client_instance_mutex);
return cdev;
} }
/** /**
* i40e_client_del_instance - removes a client instance from the list * i40e_client_del_instance - removes a client instance from the list
* @pf: pointer to the board struct * @pf: pointer to the board struct
* *
* Returns 0 on success or non-0 on error
**/ **/
static static
int i40e_client_del_instance(struct i40e_pf *pf, struct i40e_client *client) void i40e_client_del_instance(struct i40e_pf *pf)
{ {
struct i40e_client_instance *cdev, *tmp; kfree(pf->cinst);
int ret = -ENODEV; pf->cinst = NULL;
mutex_lock(&i40e_client_instance_mutex);
list_for_each_entry_safe(cdev, tmp, &i40e_client_instances, list) {
if ((cdev->lan_info.pf != pf) || (cdev->client != client))
continue;
dev_info(&pf->pdev->dev, "Deleted instance of Client %s, of dev %d bus=0x%02x func=0x%02x)\n",
client->name, pf->hw.pf_id,
pf->hw.bus.device, pf->hw.bus.func);
list_del(&cdev->list);
kfree(cdev);
ret = 0;
break;
}
mutex_unlock(&i40e_client_instance_mutex);
return ret;
} }
/** /**
...@@ -473,67 +358,50 @@ int i40e_client_del_instance(struct i40e_pf *pf, struct i40e_client *client) ...@@ -473,67 +358,50 @@ int i40e_client_del_instance(struct i40e_pf *pf, struct i40e_client *client)
**/ **/
void i40e_client_subtask(struct i40e_pf *pf) void i40e_client_subtask(struct i40e_pf *pf)
{ {
struct i40e_client *client = registered_client;
struct i40e_client_instance *cdev; struct i40e_client_instance *cdev;
struct i40e_client *client; struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
bool existing = false;
int ret = 0; int ret = 0;
if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED)) if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED))
return; return;
pf->flags &= ~I40E_FLAG_SERVICE_CLIENT_REQUESTED; pf->flags &= ~I40E_FLAG_SERVICE_CLIENT_REQUESTED;
cdev = pf->cinst;
/* If we're down or resetting, just bail */ /* If we're down or resetting, just bail */
if (test_bit(__I40E_DOWN, &pf->state) || if (test_bit(__I40E_DOWN, &pf->state) ||
test_bit(__I40E_CONFIG_BUSY, &pf->state)) test_bit(__I40E_CONFIG_BUSY, &pf->state))
return; return;
/* Check client state and instantiate client if client registered */ if (!client || !cdev)
mutex_lock(&i40e_client_mutex); return;
list_for_each_entry(client, &i40e_clients, list) {
/* first check client is registered */
if (!test_bit(__I40E_CLIENT_REGISTERED, &client->state))
continue;
/* Do we also need the LAN VSI to be up, to create instance */ /* Here we handle client opens. If the client is down, but
if (!(client->flags & I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE)) { * the netdev is up, then open the client.
/* check if L2 VSI is up, if not we are not ready */ */
if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
continue; if (!test_bit(__I40E_DOWN, &vsi->state) &&
} else { client->ops && client->ops->open) {
dev_warn(&pf->pdev->dev, "This client %s is being instantiated at probe\n", set_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
client->name); ret = client->ops->open(&cdev->lan_info, client);
if (ret) {
/* Remove failed client instance */
clear_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state);
i40e_client_del_instance(pf);
} }
/* Add the client instance to the instance list */
cdev = i40e_client_add_instance(pf, client, &existing);
if (!cdev)
continue;
if (!existing) {
dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x dev=0x%02x func=0x%02x\n",
client->name, pf->hw.pf_id,
pf->hw.bus.bus_id, pf->hw.bus.device,
pf->hw.bus.func);
} }
mutex_lock(&i40e_client_instance_mutex);
if (!test_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state)) {
/* Send an Open request to the client */
if (client->ops && client->ops->open)
ret = client->ops->open(&cdev->lan_info,
client);
if (!ret) {
set_bit(__I40E_CLIENT_INSTANCE_OPENED,
&cdev->state);
} else { } else {
/* remove client instance */ /* Likewise for client close. If the client is up, but the netdev
i40e_client_del_instance(pf, client); * is down, then close the client.
} */
if (test_bit(__I40E_DOWN, &vsi->state) &&
client->ops && client->ops->close) {
clear_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state);
client->ops->close(&cdev->lan_info, client, false);
i40e_client_release_qvlist(&cdev->lan_info);
} }
mutex_unlock(&i40e_client_instance_mutex);
} }
mutex_unlock(&i40e_client_mutex);
} }
/** /**
...@@ -601,7 +469,6 @@ int i40e_lan_del_device(struct i40e_pf *pf) ...@@ -601,7 +469,6 @@ int i40e_lan_del_device(struct i40e_pf *pf)
break; break;
} }
} }
mutex_unlock(&i40e_device_mutex); mutex_unlock(&i40e_device_mutex);
return ret; return ret;
} }
...@@ -610,22 +477,24 @@ int i40e_lan_del_device(struct i40e_pf *pf) ...@@ -610,22 +477,24 @@ int i40e_lan_del_device(struct i40e_pf *pf)
* i40e_client_release - release client specific resources * i40e_client_release - release client specific resources
* @client: pointer to the registered client * @client: pointer to the registered client
* *
* Return 0 on success or < 0 on error
**/ **/
static int i40e_client_release(struct i40e_client *client) static void i40e_client_release(struct i40e_client *client)
{ {
struct i40e_client_instance *cdev, *tmp; struct i40e_client_instance *cdev;
struct i40e_device *ldev;
struct i40e_pf *pf; struct i40e_pf *pf;
int ret = 0;
LIST_HEAD(cdevs_tmp);
mutex_lock(&i40e_client_instance_mutex); mutex_lock(&i40e_device_mutex);
list_for_each_entry_safe(cdev, tmp, &i40e_client_instances, list) { list_for_each_entry(ldev, &i40e_devices, list) {
if (strncmp(cdev->client->name, client->name, pf = ldev->pf;
I40E_CLIENT_STR_LENGTH)) cdev = pf->cinst;
if (!cdev)
continue; continue;
pf = (struct i40e_pf *)cdev->lan_info.pf;
while (test_and_set_bit(__I40E_SERVICE_SCHED,
&pf->state))
usleep_range(500, 1000);
if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) { if (test_bit(__I40E_CLIENT_INSTANCE_OPENED, &cdev->state)) {
if (client->ops && client->ops->close) if (client->ops && client->ops->close)
client->ops->close(&cdev->lan_info, client, client->ops->close(&cdev->lan_info, client,
...@@ -637,18 +506,13 @@ static int i40e_client_release(struct i40e_client *client) ...@@ -637,18 +506,13 @@ static int i40e_client_release(struct i40e_client *client)
"Client %s instance for PF id %d closed\n", "Client %s instance for PF id %d closed\n",
client->name, pf->hw.pf_id); client->name, pf->hw.pf_id);
} }
/* delete the client instance from the list */ /* delete the client instance */
list_move(&cdev->list, &cdevs_tmp); i40e_client_del_instance(pf);
dev_info(&pf->pdev->dev, "Deleted client instance of Client %s\n", dev_info(&pf->pdev->dev, "Deleted client instance of Client %s\n",
client->name); client->name);
clear_bit(__I40E_SERVICE_SCHED, &pf->state);
} }
mutex_unlock(&i40e_client_instance_mutex); mutex_unlock(&i40e_device_mutex);
/* free the client device and release its vsi */
list_for_each_entry_safe(cdev, tmp, &cdevs_tmp, list) {
kfree(cdev);
}
return ret;
} }
/** /**
...@@ -664,6 +528,7 @@ static void i40e_client_prepare(struct i40e_client *client) ...@@ -664,6 +528,7 @@ static void i40e_client_prepare(struct i40e_client *client)
mutex_lock(&i40e_device_mutex); mutex_lock(&i40e_device_mutex);
list_for_each_entry(ldev, &i40e_devices, list) { list_for_each_entry(ldev, &i40e_devices, list) {
pf = ldev->pf; pf = ldev->pf;
i40e_client_add_instance(pf);
/* Start the client subtask */ /* Start the client subtask */
pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED; pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED;
i40e_service_event_schedule(pf); i40e_service_event_schedule(pf);
...@@ -792,8 +657,8 @@ static void i40e_client_request_reset(struct i40e_info *ldev, ...@@ -792,8 +657,8 @@ static void i40e_client_request_reset(struct i40e_info *ldev,
break; break;
default: default:
dev_warn(&pf->pdev->dev, dev_warn(&pf->pdev->dev,
"Client %s instance for PF id %d request an unsupported reset: %d.\n", "Client for PF id %d requested an unsupported reset: %d.\n",
client->name, pf->hw.pf_id, reset_level); pf->hw.pf_id, reset_level);
break; break;
} }
...@@ -852,8 +717,8 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev, ...@@ -852,8 +717,8 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
} else { } else {
update = false; update = false;
dev_warn(&pf->pdev->dev, dev_warn(&pf->pdev->dev,
"Client %s instance for PF id %d request an unsupported Config: %x.\n", "Client for PF id %d request an unsupported Config: %x.\n",
client->name, pf->hw.pf_id, flag); pf->hw.pf_id, flag);
} }
if (update) { if (update) {
...@@ -878,7 +743,6 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev, ...@@ -878,7 +743,6 @@ static int i40e_client_update_vsi_ctxt(struct i40e_info *ldev,
int i40e_register_client(struct i40e_client *client) int i40e_register_client(struct i40e_client *client)
{ {
int ret = 0; int ret = 0;
enum i40e_vsi_type vsi_type;
if (!client) { if (!client) {
ret = -EIO; ret = -EIO;
...@@ -891,11 +755,9 @@ int i40e_register_client(struct i40e_client *client) ...@@ -891,11 +755,9 @@ int i40e_register_client(struct i40e_client *client)
goto out; goto out;
} }
mutex_lock(&i40e_client_mutex); if (registered_client) {
if (i40e_client_is_registered(client)) {
pr_info("i40e: Client %s has already been registered!\n", pr_info("i40e: Client %s has already been registered!\n",
client->name); client->name);
mutex_unlock(&i40e_client_mutex);
ret = -EEXIST; ret = -EEXIST;
goto out; goto out;
} }
...@@ -908,22 +770,11 @@ int i40e_register_client(struct i40e_client *client) ...@@ -908,22 +770,11 @@ int i40e_register_client(struct i40e_client *client)
client->version.major, client->version.minor, client->version.major, client->version.minor,
client->version.build, client->version.build,
i40e_client_interface_version_str); i40e_client_interface_version_str);
mutex_unlock(&i40e_client_mutex);
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
vsi_type = i40e_client_type_to_vsi_type(client->type); registered_client = client;
if (vsi_type == I40E_VSI_TYPE_UNKNOWN) {
pr_info("i40e: Failed to register client %s due to unknown client type %d\n",
client->name, client->type);
mutex_unlock(&i40e_client_mutex);
ret = -EIO;
goto out;
}
list_add(&client->list, &i40e_clients);
set_bit(__I40E_CLIENT_REGISTERED, &client->state);
mutex_unlock(&i40e_client_mutex);
i40e_client_prepare(client); i40e_client_prepare(client);
...@@ -943,29 +794,21 @@ int i40e_unregister_client(struct i40e_client *client) ...@@ -943,29 +794,21 @@ int i40e_unregister_client(struct i40e_client *client)
{ {
int ret = 0; int ret = 0;
/* When a unregister request comes through we would have to send if (registered_client != client) {
* a close for each of the client instances that were opened.
* client_release function is called to handle this.
*/
mutex_lock(&i40e_client_mutex);
if (!client || i40e_client_release(client)) {
ret = -EIO;
goto out;
}
/* TODO: check if device is in reset, or if that matters? */
if (!i40e_client_is_registered(client)) {
pr_info("i40e: Client %s has not been registered\n", pr_info("i40e: Client %s has not been registered\n",
client->name); client->name);
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
} }
clear_bit(__I40E_CLIENT_REGISTERED, &client->state); registered_client = NULL;
list_del(&client->list); /* When a unregister request comes through we would have to send
pr_info("i40e: Unregistered client %s with return code %d\n", * a close for each of the client instances that were opened.
client->name, ret); * client_release function is called to handle this.
*/
i40e_client_release(client);
pr_info("i40e: Unregistered client %s\n", client->name);
out: out:
mutex_unlock(&i40e_client_mutex);
return ret; return ret;
} }
EXPORT_SYMBOL(i40e_unregister_client); EXPORT_SYMBOL(i40e_unregister_client);
...@@ -57,11 +57,6 @@ enum i40e_client_instance_state { ...@@ -57,11 +57,6 @@ enum i40e_client_instance_state {
__I40E_CLIENT_INSTANCE_OPENED, __I40E_CLIENT_INSTANCE_OPENED,
}; };
enum i40e_client_type {
I40E_CLIENT_IWARP,
I40E_CLIENT_VMDQ2
};
struct i40e_ops; struct i40e_ops;
struct i40e_client; struct i40e_client;
...@@ -214,7 +209,8 @@ struct i40e_client { ...@@ -214,7 +209,8 @@ struct i40e_client {
u32 flags; u32 flags;
#define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0) #define I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE BIT(0)
#define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2) #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS BIT(2)
enum i40e_client_type type; u8 type;
#define I40E_CLIENT_IWARP 0
const struct i40e_client_ops *ops; /* client ops provided by the client */ const struct i40e_client_ops *ops; /* client ops provided by the client */
}; };
......
...@@ -2487,13 +2487,15 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -2487,13 +2487,15 @@ static int i40e_change_mtu(struct net_device *netdev, int new_mtu)
{ {
struct i40e_netdev_priv *np = netdev_priv(netdev); struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi; struct i40e_vsi *vsi = np->vsi;
struct i40e_pf *pf = vsi->back;
netdev_info(netdev, "changing MTU from %d to %d\n", netdev_info(netdev, "changing MTU from %d to %d\n",
netdev->mtu, new_mtu); netdev->mtu, new_mtu);
netdev->mtu = new_mtu; netdev->mtu = new_mtu;
if (netif_running(netdev)) if (netif_running(netdev))
i40e_vsi_reinit_locked(vsi); i40e_vsi_reinit_locked(vsi);
i40e_notify_client_of_l2_param_changes(vsi); pf->flags |= (I40E_FLAG_SERVICE_CLIENT_REQUESTED |
I40E_FLAG_CLIENT_L2_CHANGE);
return 0; return 0;
} }
...@@ -4463,17 +4465,16 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi) ...@@ -4463,17 +4465,16 @@ static void i40e_napi_disable_all(struct i40e_vsi *vsi)
**/ **/
static void i40e_vsi_close(struct i40e_vsi *vsi) static void i40e_vsi_close(struct i40e_vsi *vsi)
{ {
bool reset = false; struct i40e_pf *pf = vsi->back;
if (!test_and_set_bit(__I40E_DOWN, &vsi->state)) if (!test_and_set_bit(__I40E_DOWN, &vsi->state))
i40e_down(vsi); i40e_down(vsi);
i40e_vsi_free_irq(vsi); i40e_vsi_free_irq(vsi);
i40e_vsi_free_tx_resources(vsi); i40e_vsi_free_tx_resources(vsi);
i40e_vsi_free_rx_resources(vsi); i40e_vsi_free_rx_resources(vsi);
vsi->current_netdev_flags = 0; vsi->current_netdev_flags = 0;
if (test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED;
reset = true; if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state))
i40e_notify_client_of_netdev_close(vsi, reset); pf->flags |= I40E_FLAG_CLIENT_RESET;
} }
/** /**
...@@ -5542,8 +5543,6 @@ void i40e_down(struct i40e_vsi *vsi) ...@@ -5542,8 +5543,6 @@ void i40e_down(struct i40e_vsi *vsi)
i40e_clean_rx_ring(vsi->rx_rings[i]); i40e_clean_rx_ring(vsi->rx_rings[i]);
} }
i40e_notify_client_of_netdev_close(vsi, false);
} }
/** /**
...@@ -6021,8 +6020,8 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf, ...@@ -6021,8 +6020,8 @@ static int i40e_handle_lldp_event(struct i40e_pf *pf,
i40e_service_event_schedule(pf); i40e_service_event_schedule(pf);
} else { } else {
i40e_pf_unquiesce_all_vsi(pf); i40e_pf_unquiesce_all_vsi(pf);
/* Notify the client for the DCB changes */ pf->flags |= (I40E_FLAG_SERVICE_CLIENT_REQUESTED |
i40e_notify_client_of_l2_param_changes(pf->vsi[pf->lan_vsi]); I40E_FLAG_CLIENT_L2_CHANGE);
} }
exit: exit:
...@@ -7411,7 +7410,18 @@ static void i40e_service_task(struct work_struct *work) ...@@ -7411,7 +7410,18 @@ static void i40e_service_task(struct work_struct *work)
i40e_vc_process_vflr_event(pf); i40e_vc_process_vflr_event(pf);
i40e_watchdog_subtask(pf); i40e_watchdog_subtask(pf);
i40e_fdir_reinit_subtask(pf); i40e_fdir_reinit_subtask(pf);
if (pf->flags & I40E_FLAG_CLIENT_RESET) {
/* Client subtask will reopen next time through. */
i40e_notify_client_of_netdev_close(pf->vsi[pf->lan_vsi], true);
pf->flags &= ~I40E_FLAG_CLIENT_RESET;
} else {
i40e_client_subtask(pf); i40e_client_subtask(pf);
if (pf->flags & I40E_FLAG_CLIENT_L2_CHANGE) {
i40e_notify_client_of_l2_param_changes(
pf->vsi[pf->lan_vsi]);
pf->flags &= ~I40E_FLAG_CLIENT_L2_CHANGE;
}
}
i40e_sync_filters_subtask(pf); i40e_sync_filters_subtask(pf);
i40e_sync_udp_filters_subtask(pf); i40e_sync_udp_filters_subtask(pf);
i40e_clean_adminq_subtask(pf); i40e_clean_adminq_subtask(pf);
......
...@@ -1359,7 +1359,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg) ...@@ -1359,7 +1359,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
if (!vsi->info.pvid) if (!vsi->info.pvid)
vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN; vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN;
if (i40e_vf_client_capable(pf, vf->vf_id, I40E_CLIENT_IWARP) && if (i40e_vf_client_capable(pf, vf->vf_id) &&
(vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_IWARP)) { (vf->driver_caps & I40E_VIRTCHNL_VF_OFFLOAD_IWARP)) {
vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_IWARP; vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_IWARP;
set_bit(I40E_VF_STAT_IWARPENA, &vf->vf_states); set_bit(I40E_VF_STAT_IWARPENA, &vf->vf_states);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment