From patchwork Wed Mar 29 21:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 744982 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vthPp5Rzcz9s2s for ; Thu, 30 Mar 2017 08:54:54 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932470AbdC2VxN (ORCPT ); Wed, 29 Mar 2017 17:53:13 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:28616 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932445AbdC2VwA (ORCPT ); Wed, 29 Mar 2017 17:52:00 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v2TLpw5m030505 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Mar 2017 21:51:58 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v2TLpvxg005817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 29 Mar 2017 21:51:58 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id v2TLptjH021584; Wed, 29 Mar 2017 21:51:56 GMT Received: from ca-ldom103.us.oracle.com (/10.129.68.23) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Mar 2017 14:51:55 -0700 From: Jag Raman To: sparclinux@vger.kernel.org Cc: davem@davemloft.net, bijan.mottahedeh@oracle.com, liam.merwick@oracle.com, sunit.jain@oracle.com, jag.raman@oracle.com Subject: [PATCH 1/5] sparc64: expand LDC interface Date: Wed, 29 Mar 2017 17:51:42 -0400 Message-Id: <21bdb86a1b8bd602b635ed44fca7522476313bff.1490823535.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org 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 - ldc_enable_hv_intr: Enable HV interrupt for the device associated with given LDC channel - ldc_disable_hv_intr: Disable HV interrupt for the device associated with given LDC channel Signed-off-by: Jagannathan Raman Reviewed-by: Aaron Young Reviewed-by: Alexandre Chartre Reviewed-by: Bijan Mottahedeh Reviewed-by: Liam Merwick --- arch/sparc/include/asm/ldc.h | 13 +++++++ arch/sparc/kernel/ldc.c | 83 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 84 insertions(+), 12 deletions(-) diff --git a/arch/sparc/include/asm/ldc.h b/arch/sparc/include/asm/ldc.h index 6e9004a..e7be6c3 100644 --- a/arch/sparc/include/asm/ldc.h +++ b/arch/sparc/include/asm/ldc.h @@ -24,6 +24,9 @@ struct ldc_channel_config { u32 mtu; unsigned int rx_irq; unsigned int tx_irq; + u64 rx_ino; + u64 tx_ino; + u64 dev_handle; u8 mode; #define LDC_MODE_RAW 0x00 #define LDC_MODE_UNRELIABLE 0x01 @@ -48,6 +51,8 @@ struct ldc_channel_config { #define LDC_STATE_READY 0x03 #define LDC_STATE_CONNECTED 0x04 +#define LDC_PACKET_SIZE 64 + struct ldc_channel; /* Allocate state for a channel. */ @@ -72,6 +77,10 @@ struct ldc_channel *ldc_alloc(unsigned long id, int ldc_disconnect(struct ldc_channel *lp); int ldc_state(struct ldc_channel *lp); +void ldc_set_state(struct ldc_channel *lp, u8 state); +int ldc_mode(struct ldc_channel *lp); +void ldc_print(struct ldc_channel *lp); +int ldc_rx_reset(struct ldc_channel *lp); /* Read and write operations. Only valid when the link is up. */ int ldc_write(struct ldc_channel *lp, const void *buf, @@ -137,4 +146,8 @@ void ldc_free_exp_dring(struct ldc_channel *lp, void *buf, unsigned int len, struct ldc_trans_cookie *cookies, int ncookies); +void ldc_enable_hv_intr(struct ldc_channel *lp); + +void ldc_disable_hv_intr(struct ldc_channel *lp); + #endif /* _SPARC64_LDC_H */ diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 59d5038..6e28a3b 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -34,7 +34,6 @@ static char version[] = DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; -#define LDC_PACKET_SIZE 64 /* Packet header layout for unreliable and reliable mode frames. * When in RAW mode, packets are simply straight 64-byte payloads @@ -196,15 +195,6 @@ struct ldc_channel { } } -static void ldc_set_state(struct ldc_channel *lp, u8 state) -{ - ldcdbg(STATE, "STATE (%s) --> (%s)\n", - state_to_str(lp->state), - state_to_str(state)); - - lp->state = state; -} - static unsigned long __advance(unsigned long off, unsigned long num_entries) { off += LDC_PACKET_SIZE; @@ -782,6 +772,39 @@ static int process_data_ack(struct ldc_channel *lp, return 0; } +void ldc_enable_hv_intr(struct ldc_channel *lp) +{ + unsigned long flags; + + spin_lock_irqsave(&lp->lock, flags); + + ldcdbg(RX, "%s: dh=%llu, ino=%llu\n", __func__, + lp->cfg.dev_handle, lp->cfg.rx_ino); + sun4v_vintr_set_valid(lp->cfg.dev_handle, lp->cfg.rx_ino, + HV_INTR_ENABLED); + + spin_unlock_irqrestore(&lp->lock, flags); + +} +EXPORT_SYMBOL(ldc_enable_hv_intr); + + +void ldc_disable_hv_intr(struct ldc_channel *lp) +{ + unsigned long flags; + + spin_lock_irqsave(&lp->lock, flags); + + ldcdbg(RX, "%s: dh=%llu, ino=%llu\n", __func__, + lp->cfg.dev_handle, lp->cfg.rx_ino); + sun4v_vintr_set_valid(lp->cfg.dev_handle, lp->cfg.rx_ino, + HV_INTR_DISABLED); + + spin_unlock_irqrestore(&lp->lock, flags); + +} +EXPORT_SYMBOL(ldc_disable_hv_intr); + static void send_events(struct ldc_channel *lp, unsigned int event_mask) { if (event_mask & LDC_EVENT_RESET) @@ -829,7 +852,7 @@ static irqreturn_t ldc_rx(int irq, void *dev_id) * everything. */ if (lp->flags & LDC_FLAG_RESET) { - (void) __set_rx_head(lp, lp->rx_tail); + (void) ldc_rx_reset(lp); goto out; } @@ -1447,6 +1470,42 @@ int ldc_state(struct ldc_channel *lp) } EXPORT_SYMBOL(ldc_state); +void ldc_set_state(struct ldc_channel *lp, u8 state) +{ + ldcdbg(STATE, "STATE (%s) --> (%s)\n", + state_to_str(lp->state), + state_to_str(state)); + + lp->state = state; +} +EXPORT_SYMBOL(ldc_set_state); + +int ldc_mode(struct ldc_channel *lp) +{ + return lp->cfg.mode; +} +EXPORT_SYMBOL(ldc_mode); + +int ldc_rx_reset(struct ldc_channel *lp) +{ + return __set_rx_head(lp, lp->rx_tail); +} +EXPORT_SYMBOL(ldc_rx_reset); + +void ldc_print(struct ldc_channel *lp) +{ + pr_info("%s: id=0x%lx flags=0x%x state=%s cstate=0x%lx hsstate=0x%x\n" + "\trx_h=0x%lx rx_t=0x%lx rx_n=%ld\n" + "\ttx_h=0x%lx tx_t=0x%lx tx_n=%ld\n" + "\trcv_nxt=%u snd_nxt=%u\n", + __func__, lp->id, lp->flags, state_to_str(lp->state), + lp->chan_state, lp->hs_state, + lp->rx_head, lp->rx_tail, lp->rx_num_entries, + lp->tx_head, lp->tx_tail, lp->tx_num_entries, + lp->rcv_nxt, lp->snd_nxt); +} +EXPORT_SYMBOL(ldc_print); + static int write_raw(struct ldc_channel *lp, const void *buf, unsigned int size) { struct ldc_packet *p; @@ -1592,7 +1651,7 @@ static int rx_bad_seq(struct ldc_channel *lp, struct ldc_packet *p, if (err) return err; - err = __set_rx_head(lp, lp->rx_tail); + err = ldc_rx_reset(lp); if (err < 0) return ldc_abort(lp);