diff options
author | Jag Raman <jag.raman@oracle.com> | 2017-06-09 12:29:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-10 17:10:54 -0400 |
commit | 85762a65c1106daa0930bc2ed0d7792511647168 (patch) | |
tree | ac67d12eade283effe9f871c6866d05dfc9f1a52 /arch/sparc | |
parent | 95c4629d92d15d10e5f7c55bfb72583f96a91374 (diff) |
sparc64: expand LDC interface
Add the following LDC APIs which are planned to be used by
LDC clients in the future:
- ldc_set_state: Sets given LDC channel to given state
- ldc_mode: Returns the mode of given LDC channel
- ldc_print: Prints info about given LDC channel
- ldc_rx_reset: Reset the RX queue of given LDC channel
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
Reviewed-by: Aaron Young <aaron.young@oracle.com>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/include/asm/ldc.h | 8 | ||||
-rw-r--r-- | arch/sparc/kernel/ldc.c | 46 |
2 files changed, 42 insertions, 12 deletions
diff --git a/arch/sparc/include/asm/ldc.h b/arch/sparc/include/asm/ldc.h index 6e9004aa6f25..698738a10414 100644 --- a/arch/sparc/include/asm/ldc.h +++ b/arch/sparc/include/asm/ldc.h | |||
@@ -48,6 +48,8 @@ struct ldc_channel_config { | |||
48 | #define LDC_STATE_READY 0x03 | 48 | #define LDC_STATE_READY 0x03 |
49 | #define LDC_STATE_CONNECTED 0x04 | 49 | #define LDC_STATE_CONNECTED 0x04 |
50 | 50 | ||
51 | #define LDC_PACKET_SIZE 64 | ||
52 | |||
51 | struct ldc_channel; | 53 | struct ldc_channel; |
52 | 54 | ||
53 | /* Allocate state for a channel. */ | 55 | /* Allocate state for a channel. */ |
@@ -72,6 +74,12 @@ int ldc_connect(struct ldc_channel *lp); | |||
72 | int ldc_disconnect(struct ldc_channel *lp); | 74 | int ldc_disconnect(struct ldc_channel *lp); |
73 | 75 | ||
74 | int ldc_state(struct ldc_channel *lp); | 76 | int ldc_state(struct ldc_channel *lp); |
77 | void ldc_set_state(struct ldc_channel *lp, u8 state); | ||
78 | int ldc_mode(struct ldc_channel *lp); | ||
79 | void __ldc_print(struct ldc_channel *lp, const char *caller); | ||
80 | int ldc_rx_reset(struct ldc_channel *lp); | ||
81 | |||
82 | #define ldc_print(chan) __ldc_print(chan, __func__) | ||
75 | 83 | ||
76 | /* Read and write operations. Only valid when the link is up. */ | 84 | /* Read and write operations. Only valid when the link is up. */ |
77 | int ldc_write(struct ldc_channel *lp, const void *buf, | 85 | int ldc_write(struct ldc_channel *lp, const void *buf, |
diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 59d503866431..77c34b00eccc 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c | |||
@@ -34,7 +34,6 @@ | |||
34 | 34 | ||
35 | static char version[] = | 35 | static char version[] = |
36 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; | 36 | DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; |
37 | #define LDC_PACKET_SIZE 64 | ||
38 | 37 | ||
39 | /* Packet header layout for unreliable and reliable mode frames. | 38 | /* Packet header layout for unreliable and reliable mode frames. |
40 | * When in RAW mode, packets are simply straight 64-byte payloads | 39 | * When in RAW mode, packets are simply straight 64-byte payloads |
@@ -196,15 +195,6 @@ static const char *state_to_str(u8 state) | |||
196 | } | 195 | } |
197 | } | 196 | } |
198 | 197 | ||
199 | static void ldc_set_state(struct ldc_channel *lp, u8 state) | ||
200 | { | ||
201 | ldcdbg(STATE, "STATE (%s) --> (%s)\n", | ||
202 | state_to_str(lp->state), | ||
203 | state_to_str(state)); | ||
204 | |||
205 | lp->state = state; | ||
206 | } | ||
207 | |||
208 | static unsigned long __advance(unsigned long off, unsigned long num_entries) | 198 | static unsigned long __advance(unsigned long off, unsigned long num_entries) |
209 | { | 199 | { |
210 | off += LDC_PACKET_SIZE; | 200 | off += LDC_PACKET_SIZE; |
@@ -829,7 +819,7 @@ static irqreturn_t ldc_rx(int irq, void *dev_id) | |||
829 | * everything. | 819 | * everything. |
830 | */ | 820 | */ |
831 | if (lp->flags & LDC_FLAG_RESET) { | 821 | if (lp->flags & LDC_FLAG_RESET) { |
832 | (void) __set_rx_head(lp, lp->rx_tail); | 822 | (void) ldc_rx_reset(lp); |
833 | goto out; | 823 | goto out; |
834 | } | 824 | } |
835 | 825 | ||
@@ -1447,6 +1437,38 @@ int ldc_state(struct ldc_channel *lp) | |||
1447 | } | 1437 | } |
1448 | EXPORT_SYMBOL(ldc_state); | 1438 | EXPORT_SYMBOL(ldc_state); |
1449 | 1439 | ||
1440 | void ldc_set_state(struct ldc_channel *lp, u8 state) | ||
1441 | { | ||
1442 | ldcdbg(STATE, "STATE (%s) --> (%s)\n", | ||
1443 | state_to_str(lp->state), | ||
1444 | state_to_str(state)); | ||
1445 | |||
1446 | lp->state = state; | ||
1447 | } | ||
1448 | |||
1449 | int ldc_mode(struct ldc_channel *lp) | ||
1450 | { | ||
1451 | return lp->cfg.mode; | ||
1452 | } | ||
1453 | |||
1454 | int ldc_rx_reset(struct ldc_channel *lp) | ||
1455 | { | ||
1456 | return __set_rx_head(lp, lp->rx_tail); | ||
1457 | } | ||
1458 | |||
1459 | void __ldc_print(struct ldc_channel *lp, const char *caller) | ||
1460 | { | ||
1461 | pr_info("%s: id=0x%lx flags=0x%x state=%s cstate=0x%lx hsstate=0x%x\n" | ||
1462 | "\trx_h=0x%lx rx_t=0x%lx rx_n=%ld\n" | ||
1463 | "\ttx_h=0x%lx tx_t=0x%lx tx_n=%ld\n" | ||
1464 | "\trcv_nxt=%u snd_nxt=%u\n", | ||
1465 | caller, lp->id, lp->flags, state_to_str(lp->state), | ||
1466 | lp->chan_state, lp->hs_state, | ||
1467 | lp->rx_head, lp->rx_tail, lp->rx_num_entries, | ||
1468 | lp->tx_head, lp->tx_tail, lp->tx_num_entries, | ||
1469 | lp->rcv_nxt, lp->snd_nxt); | ||
1470 | } | ||
1471 | |||
1450 | static int write_raw(struct ldc_channel *lp, const void *buf, unsigned int size) | 1472 | static int write_raw(struct ldc_channel *lp, const void *buf, unsigned int size) |
1451 | { | 1473 | { |
1452 | struct ldc_packet *p; | 1474 | struct ldc_packet *p; |
@@ -1592,7 +1614,7 @@ static int rx_bad_seq(struct ldc_channel *lp, struct ldc_packet *p, | |||
1592 | if (err) | 1614 | if (err) |
1593 | return err; | 1615 | return err; |
1594 | 1616 | ||
1595 | err = __set_rx_head(lp, lp->rx_tail); | 1617 | err = ldc_rx_reset(lp); |
1596 | if (err < 0) | 1618 | if (err < 0) |
1597 | return ldc_abort(lp); | 1619 | return ldc_abort(lp); |
1598 | 1620 | ||