提交 a0509cbe 编写于 作者: G Gavin Shan 提交者: David S. Miller

net/ncsi: Allow to extend NCSI request properties

There is only one NCSI request property for now: the response for
the sent command need drive the workqueue or not. So we had one
field (@driven) for the purpose. We lost the flexibility to extend
NCSI request properties.

This replaces @driven with @flags and @req_flags in NCSI request
and NCSI command argument struct. Each bit of the newly introduced
field can be used for one property. No functional changes introduced.
Signed-off-by: NGavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: NJoel Stanley <joel@jms.id.au>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a15af54f
...@@ -207,7 +207,8 @@ struct ncsi_package { ...@@ -207,7 +207,8 @@ struct ncsi_package {
struct ncsi_request { struct ncsi_request {
unsigned char id; /* Request ID - 0 to 255 */ unsigned char id; /* Request ID - 0 to 255 */
bool used; /* Request that has been assigned */ bool used; /* Request that has been assigned */
bool driven; /* Drive state machine */ unsigned int flags; /* NCSI request property */
#define NCSI_REQ_FLAG_EVENT_DRIVEN 1
struct ncsi_dev_priv *ndp; /* Associated NCSI device */ struct ncsi_dev_priv *ndp; /* Associated NCSI device */
struct sk_buff *cmd; /* Associated NCSI command packet */ struct sk_buff *cmd; /* Associated NCSI command packet */
struct sk_buff *rsp; /* Associated NCSI response packet */ struct sk_buff *rsp; /* Associated NCSI response packet */
...@@ -276,7 +277,7 @@ struct ncsi_cmd_arg { ...@@ -276,7 +277,7 @@ struct ncsi_cmd_arg {
unsigned char package; /* Destination package ID */ unsigned char package; /* Destination package ID */
unsigned char channel; /* Detination channel ID or 0x1f */ unsigned char channel; /* Detination channel ID or 0x1f */
unsigned short payload; /* Command packet payload length */ unsigned short payload; /* Command packet payload length */
bool driven; /* Drive the state machine? */ unsigned int req_flags; /* NCSI request properties */
union { union {
unsigned char bytes[16]; /* Command packet specific data */ unsigned char bytes[16]; /* Command packet specific data */
unsigned short words[8]; unsigned short words[8];
...@@ -315,7 +316,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp, ...@@ -315,7 +316,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
unsigned char id, unsigned char id,
struct ncsi_package **np, struct ncsi_package **np,
struct ncsi_channel **nc); struct ncsi_channel **nc);
struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven); struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,
unsigned int req_flags);
void ncsi_free_request(struct ncsi_request *nr); void ncsi_free_request(struct ncsi_request *nr);
struct ncsi_dev *ncsi_find_dev(struct net_device *dev); struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
int ncsi_process_next_channel(struct ncsi_dev_priv *ndp); int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
......
...@@ -272,7 +272,7 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca) ...@@ -272,7 +272,7 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)
struct sk_buff *skb; struct sk_buff *skb;
struct ncsi_request *nr; struct ncsi_request *nr;
nr = ncsi_alloc_request(ndp, nca->driven); nr = ncsi_alloc_request(ndp, nca->req_flags);
if (!nr) if (!nr)
return NULL; return NULL;
......
...@@ -194,7 +194,7 @@ static void ncsi_channel_monitor(unsigned long data) ...@@ -194,7 +194,7 @@ static void ncsi_channel_monitor(unsigned long data)
nca.package = np->id; nca.package = np->id;
nca.channel = nc->id; nca.channel = nc->id;
nca.type = NCSI_PKT_CMD_GLS; nca.type = NCSI_PKT_CMD_GLS;
nca.driven = false; nca.req_flags = 0;
ret = ncsi_xmit_cmd(&nca); ret = ncsi_xmit_cmd(&nca);
if (ret) { if (ret) {
netdev_err(ndp->ndev.dev, "Error %d sending GLS\n", netdev_err(ndp->ndev.dev, "Error %d sending GLS\n",
...@@ -419,7 +419,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp, ...@@ -419,7 +419,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
* be same. Otherwise, the bogus response might be replied. So * be same. Otherwise, the bogus response might be replied. So
* the available IDs are allocated in round-robin fashion. * the available IDs are allocated in round-robin fashion.
*/ */
struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven) struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,
unsigned int req_flags)
{ {
struct ncsi_request *nr = NULL; struct ncsi_request *nr = NULL;
int i, limit = ARRAY_SIZE(ndp->requests); int i, limit = ARRAY_SIZE(ndp->requests);
...@@ -433,7 +434,7 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven) ...@@ -433,7 +434,7 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven)
nr = &ndp->requests[i]; nr = &ndp->requests[i];
nr->used = true; nr->used = true;
nr->driven = driven; nr->flags = req_flags;
ndp->request_id = i + 1; ndp->request_id = i + 1;
goto found; goto found;
} }
...@@ -445,7 +446,7 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven) ...@@ -445,7 +446,7 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven)
nr = &ndp->requests[i]; nr = &ndp->requests[i];
nr->used = true; nr->used = true;
nr->driven = driven; nr->flags = req_flags;
ndp->request_id = i + 1; ndp->request_id = i + 1;
goto found; goto found;
} }
...@@ -473,7 +474,7 @@ void ncsi_free_request(struct ncsi_request *nr) ...@@ -473,7 +474,7 @@ void ncsi_free_request(struct ncsi_request *nr)
nr->cmd = NULL; nr->cmd = NULL;
nr->rsp = NULL; nr->rsp = NULL;
nr->used = false; nr->used = false;
driven = nr->driven; driven = !!(nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN);
spin_unlock_irqrestore(&ndp->lock, flags); spin_unlock_irqrestore(&ndp->lock, flags);
if (driven && cmd && --ndp->pending_req_num == 0) if (driven && cmd && --ndp->pending_req_num == 0)
...@@ -527,7 +528,7 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp) ...@@ -527,7 +528,7 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)
int ret; int ret;
nca.ndp = ndp; nca.ndp = ndp;
nca.driven = true; nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
switch (nd->state) { switch (nd->state) {
case ncsi_dev_state_suspend: case ncsi_dev_state_suspend:
nd->state = ncsi_dev_state_suspend_select; nd->state = ncsi_dev_state_suspend_select;
...@@ -596,7 +597,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) ...@@ -596,7 +597,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp)
int ret; int ret;
nca.ndp = ndp; nca.ndp = ndp;
nca.driven = true; nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
switch (nd->state) { switch (nd->state) {
case ncsi_dev_state_config: case ncsi_dev_state_config:
case ncsi_dev_state_config_sp: case ncsi_dev_state_config_sp:
...@@ -825,7 +826,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) ...@@ -825,7 +826,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
int ret; int ret;
nca.ndp = ndp; nca.ndp = ndp;
nca.driven = true; nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN;
switch (nd->state) { switch (nd->state) {
case ncsi_dev_state_probe: case ncsi_dev_state_probe:
nd->state = ncsi_dev_state_probe_deselect; nd->state = ncsi_dev_state_probe_deselect;
...@@ -1101,7 +1102,7 @@ static int ncsi_inet6addr_event(struct notifier_block *this, ...@@ -1101,7 +1102,7 @@ static int ncsi_inet6addr_event(struct notifier_block *this,
return NOTIFY_OK; return NOTIFY_OK;
nca.ndp = ndp; nca.ndp = ndp;
nca.driven = false; nca.req_flags = 0;
nca.package = np->id; nca.package = np->id;
nca.channel = nc->id; nca.channel = nc->id;
nca.dwords[0] = nc->caps[NCSI_CAP_MC].cap; nca.dwords[0] = nc->caps[NCSI_CAP_MC].cap;
......
...@@ -317,7 +317,7 @@ static int ncsi_rsp_handler_gls(struct ncsi_request *nr) ...@@ -317,7 +317,7 @@ static int ncsi_rsp_handler_gls(struct ncsi_request *nr)
ncm->data[3] = ntohl(rsp->other); ncm->data[3] = ntohl(rsp->other);
ncm->data[4] = ntohl(rsp->oem_status); ncm->data[4] = ntohl(rsp->oem_status);
if (nr->driven) if (nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN)
return 0; return 0;
/* Reset the channel monitor if it has been enabled */ /* Reset the channel monitor if it has been enabled */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册