diff options
author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2016-10-03 20:25:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-10-04 02:11:50 -0400 |
commit | a0509cbeef5dafbab42c42622e012bcc94c3eb9e (patch) | |
tree | 9f4493950b3f7b8c7f5bc2f33774edaf608383bd /net/ncsi | |
parent | a15af54f8f2a32d629781417503843bfbd02a004 (diff) |
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: Gavin Shan <gwshan@linux.vnet.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ncsi')
-rw-r--r-- | net/ncsi/internal.h | 8 | ||||
-rw-r--r-- | net/ncsi/ncsi-cmd.c | 2 | ||||
-rw-r--r-- | net/ncsi/ncsi-manage.c | 19 | ||||
-rw-r--r-- | net/ncsi/ncsi-rsp.c | 2 |
4 files changed, 17 insertions, 14 deletions
diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index c956fe8d80c3..26e929595b5e 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h | |||
@@ -207,7 +207,8 @@ struct ncsi_package { | |||
207 | struct ncsi_request { | 207 | struct ncsi_request { |
208 | unsigned char id; /* Request ID - 0 to 255 */ | 208 | unsigned char id; /* Request ID - 0 to 255 */ |
209 | bool used; /* Request that has been assigned */ | 209 | bool used; /* Request that has been assigned */ |
210 | bool driven; /* Drive state machine */ | 210 | unsigned int flags; /* NCSI request property */ |
211 | #define NCSI_REQ_FLAG_EVENT_DRIVEN 1 | ||
211 | struct ncsi_dev_priv *ndp; /* Associated NCSI device */ | 212 | struct ncsi_dev_priv *ndp; /* Associated NCSI device */ |
212 | struct sk_buff *cmd; /* Associated NCSI command packet */ | 213 | struct sk_buff *cmd; /* Associated NCSI command packet */ |
213 | struct sk_buff *rsp; /* Associated NCSI response packet */ | 214 | struct sk_buff *rsp; /* Associated NCSI response packet */ |
@@ -276,7 +277,7 @@ struct ncsi_cmd_arg { | |||
276 | unsigned char package; /* Destination package ID */ | 277 | unsigned char package; /* Destination package ID */ |
277 | unsigned char channel; /* Detination channel ID or 0x1f */ | 278 | unsigned char channel; /* Detination channel ID or 0x1f */ |
278 | unsigned short payload; /* Command packet payload length */ | 279 | unsigned short payload; /* Command packet payload length */ |
279 | bool driven; /* Drive the state machine? */ | 280 | unsigned int req_flags; /* NCSI request properties */ |
280 | union { | 281 | union { |
281 | unsigned char bytes[16]; /* Command packet specific data */ | 282 | unsigned char bytes[16]; /* Command packet specific data */ |
282 | unsigned short words[8]; | 283 | unsigned short words[8]; |
@@ -315,7 +316,8 @@ void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp, | |||
315 | unsigned char id, | 316 | unsigned char id, |
316 | struct ncsi_package **np, | 317 | struct ncsi_package **np, |
317 | struct ncsi_channel **nc); | 318 | struct ncsi_channel **nc); |
318 | struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven); | 319 | struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, |
320 | unsigned int req_flags); | ||
319 | void ncsi_free_request(struct ncsi_request *nr); | 321 | void ncsi_free_request(struct ncsi_request *nr); |
320 | struct ncsi_dev *ncsi_find_dev(struct net_device *dev); | 322 | struct ncsi_dev *ncsi_find_dev(struct net_device *dev); |
321 | int ncsi_process_next_channel(struct ncsi_dev_priv *ndp); | 323 | int ncsi_process_next_channel(struct ncsi_dev_priv *ndp); |
diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c index 21057a8ceeac..db7083bfd476 100644 --- a/net/ncsi/ncsi-cmd.c +++ b/net/ncsi/ncsi-cmd.c | |||
@@ -272,7 +272,7 @@ static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca) | |||
272 | struct sk_buff *skb; | 272 | struct sk_buff *skb; |
273 | struct ncsi_request *nr; | 273 | struct ncsi_request *nr; |
274 | 274 | ||
275 | nr = ncsi_alloc_request(ndp, nca->driven); | 275 | nr = ncsi_alloc_request(ndp, nca->req_flags); |
276 | if (!nr) | 276 | if (!nr) |
277 | return NULL; | 277 | return NULL; |
278 | 278 | ||
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index 00ce2c7fdb15..adf5401817c2 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c | |||
@@ -194,7 +194,7 @@ static void ncsi_channel_monitor(unsigned long data) | |||
194 | nca.package = np->id; | 194 | nca.package = np->id; |
195 | nca.channel = nc->id; | 195 | nca.channel = nc->id; |
196 | nca.type = NCSI_PKT_CMD_GLS; | 196 | nca.type = NCSI_PKT_CMD_GLS; |
197 | nca.driven = false; | 197 | nca.req_flags = 0; |
198 | ret = ncsi_xmit_cmd(&nca); | 198 | ret = ncsi_xmit_cmd(&nca); |
199 | if (ret) { | 199 | if (ret) { |
200 | netdev_err(ndp->ndev.dev, "Error %d sending GLS\n", | 200 | 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 | * be same. Otherwise, the bogus response might be replied. So | 419 | * be same. Otherwise, the bogus response might be replied. So |
420 | * the available IDs are allocated in round-robin fashion. | 420 | * the available IDs are allocated in round-robin fashion. |
421 | */ | 421 | */ |
422 | struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven) | 422 | struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, |
423 | unsigned int req_flags) | ||
423 | { | 424 | { |
424 | struct ncsi_request *nr = NULL; | 425 | struct ncsi_request *nr = NULL; |
425 | int i, limit = ARRAY_SIZE(ndp->requests); | 426 | 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 | 434 | ||
434 | nr = &ndp->requests[i]; | 435 | nr = &ndp->requests[i]; |
435 | nr->used = true; | 436 | nr->used = true; |
436 | nr->driven = driven; | 437 | nr->flags = req_flags; |
437 | ndp->request_id = i + 1; | 438 | ndp->request_id = i + 1; |
438 | goto found; | 439 | goto found; |
439 | } | 440 | } |
@@ -445,7 +446,7 @@ struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven) | |||
445 | 446 | ||
446 | nr = &ndp->requests[i]; | 447 | nr = &ndp->requests[i]; |
447 | nr->used = true; | 448 | nr->used = true; |
448 | nr->driven = driven; | 449 | nr->flags = req_flags; |
449 | ndp->request_id = i + 1; | 450 | ndp->request_id = i + 1; |
450 | goto found; | 451 | goto found; |
451 | } | 452 | } |
@@ -473,7 +474,7 @@ void ncsi_free_request(struct ncsi_request *nr) | |||
473 | nr->cmd = NULL; | 474 | nr->cmd = NULL; |
474 | nr->rsp = NULL; | 475 | nr->rsp = NULL; |
475 | nr->used = false; | 476 | nr->used = false; |
476 | driven = nr->driven; | 477 | driven = !!(nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN); |
477 | spin_unlock_irqrestore(&ndp->lock, flags); | 478 | spin_unlock_irqrestore(&ndp->lock, flags); |
478 | 479 | ||
479 | if (driven && cmd && --ndp->pending_req_num == 0) | 480 | if (driven && cmd && --ndp->pending_req_num == 0) |
@@ -527,7 +528,7 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp) | |||
527 | int ret; | 528 | int ret; |
528 | 529 | ||
529 | nca.ndp = ndp; | 530 | nca.ndp = ndp; |
530 | nca.driven = true; | 531 | nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN; |
531 | switch (nd->state) { | 532 | switch (nd->state) { |
532 | case ncsi_dev_state_suspend: | 533 | case ncsi_dev_state_suspend: |
533 | nd->state = ncsi_dev_state_suspend_select; | 534 | nd->state = ncsi_dev_state_suspend_select; |
@@ -596,7 +597,7 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) | |||
596 | int ret; | 597 | int ret; |
597 | 598 | ||
598 | nca.ndp = ndp; | 599 | nca.ndp = ndp; |
599 | nca.driven = true; | 600 | nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN; |
600 | switch (nd->state) { | 601 | switch (nd->state) { |
601 | case ncsi_dev_state_config: | 602 | case ncsi_dev_state_config: |
602 | case ncsi_dev_state_config_sp: | 603 | case ncsi_dev_state_config_sp: |
@@ -825,7 +826,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) | |||
825 | int ret; | 826 | int ret; |
826 | 827 | ||
827 | nca.ndp = ndp; | 828 | nca.ndp = ndp; |
828 | nca.driven = true; | 829 | nca.req_flags = NCSI_REQ_FLAG_EVENT_DRIVEN; |
829 | switch (nd->state) { | 830 | switch (nd->state) { |
830 | case ncsi_dev_state_probe: | 831 | case ncsi_dev_state_probe: |
831 | nd->state = ncsi_dev_state_probe_deselect; | 832 | nd->state = ncsi_dev_state_probe_deselect; |
@@ -1101,7 +1102,7 @@ static int ncsi_inet6addr_event(struct notifier_block *this, | |||
1101 | return NOTIFY_OK; | 1102 | return NOTIFY_OK; |
1102 | 1103 | ||
1103 | nca.ndp = ndp; | 1104 | nca.ndp = ndp; |
1104 | nca.driven = false; | 1105 | nca.req_flags = 0; |
1105 | nca.package = np->id; | 1106 | nca.package = np->id; |
1106 | nca.channel = nc->id; | 1107 | nca.channel = nc->id; |
1107 | nca.dwords[0] = nc->caps[NCSI_CAP_MC].cap; | 1108 | nca.dwords[0] = nc->caps[NCSI_CAP_MC].cap; |
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index af84389a6bf1..86cdaebd8d9e 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c | |||
@@ -317,7 +317,7 @@ static int ncsi_rsp_handler_gls(struct ncsi_request *nr) | |||
317 | ncm->data[3] = ntohl(rsp->other); | 317 | ncm->data[3] = ntohl(rsp->other); |
318 | ncm->data[4] = ntohl(rsp->oem_status); | 318 | ncm->data[4] = ntohl(rsp->oem_status); |
319 | 319 | ||
320 | if (nr->driven) | 320 | if (nr->flags & NCSI_REQ_FLAG_EVENT_DRIVEN) |
321 | return 0; | 321 | return 0; |
322 | 322 | ||
323 | /* Reset the channel monitor if it has been enabled */ | 323 | /* Reset the channel monitor if it has been enabled */ |