aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorJag Raman <jag.raman@oracle.com>2017-06-09 12:29:28 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-10 17:10:54 -0400
commit85762a65c1106daa0930bc2ed0d7792511647168 (patch)
treeac67d12eade283effe9f871c6866d05dfc9f1a52 /arch/sparc
parent95c4629d92d15d10e5f7c55bfb72583f96a91374 (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.h8
-rw-r--r--arch/sparc/kernel/ldc.c46
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
51struct ldc_channel; 53struct 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);
72int ldc_disconnect(struct ldc_channel *lp); 74int ldc_disconnect(struct ldc_channel *lp);
73 75
74int ldc_state(struct ldc_channel *lp); 76int ldc_state(struct ldc_channel *lp);
77void ldc_set_state(struct ldc_channel *lp, u8 state);
78int ldc_mode(struct ldc_channel *lp);
79void __ldc_print(struct ldc_channel *lp, const char *caller);
80int 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. */
77int ldc_write(struct ldc_channel *lp, const void *buf, 85int 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
35static char version[] = 35static 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
199static 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
208static unsigned long __advance(unsigned long off, unsigned long num_entries) 198static 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}
1448EXPORT_SYMBOL(ldc_state); 1438EXPORT_SYMBOL(ldc_state);
1449 1439
1440void 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
1449int ldc_mode(struct ldc_channel *lp)
1450{
1451 return lp->cfg.mode;
1452}
1453
1454int ldc_rx_reset(struct ldc_channel *lp)
1455{
1456 return __set_rx_head(lp, lp->rx_tail);
1457}
1458
1459void __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
1450static int write_raw(struct ldc_channel *lp, const void *buf, unsigned int size) 1472static 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