misc: mic: SCIF driver
Subsystems (2)
cover misc: mic: SCIF driver
The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a low level communications API across PCIe currently implemented for MIC. Currently SCIF provides inter-node communication within a single host platform, where a node is a MIC Coprocessor or Xeon based host. SCIF abstracts the details of communicating over the PCIe bus while providing an API that is symmetric across all the nodes in the PCIe network. An important design objective for SCIF is to deliver the maximum possible performance given the communication abilities of the hardware. SCIF has been used to implement an offload compiler runtime and OFED support for MPI implementations for MIC coprocessors.
==== SCIF API Components ====
The SCIF API has the following parts:
1. Connection establishment using a client server model
2. Byte stream messaging intended for short messages
3. Node enumeration to determine online nodes
4. Poll semantics for detection of incoming connections and messages
5. Memory registration to pin down pages
6. Remote memory mapping for low latency CPU accesses via mmap
7. Remote DMA (RDMA) for high bandwidth DMA transfers
8. Fence APIs for RDMA synchronization
SCIF exposes the notion of a connection which can be used by peer processes on nodes in a SCIF PCIe "network" to share memory "windows" and to communicate. A process in a SCIF node initiates a SCIF connection to a peer process on a different node via a SCIF "endpoint". SCIF endpoints support messaging APIs which are similar to connection oriented socket APIs. Connected SCIF endpoints can also register local memory which is followed by data transfer using either DMA, CPU copies or remote memory mapping via mmap. SCIF supports both user and kernel mode clients which are functionally equivalent.
==== SCIF Performance for MIC ====
DMA bandwidth comparison between the TCP (over ethernet over PCIe) stack versus SCIF shows the performance advantages of SCIF for HPC applications and runtimes.
Comparison of TCP and SCIF based BW
Throughput (GB/sec)
8 + PCIe Bandwidth ******
+ TCP ######
7 + ************************************** SCIF %%%%%%
| %%%%%%%%%%%%%%%%%%%
6 + %%%%
| %%
| %%%
5 + %%
| %%
4 + %%
| %%
3 + %%
| %
2 + %%
| %%
| %
1 +
+ ######################################
0 +++---+++--+--+-+--+--+-++-+--+-++-+--+-++-+-
1 10 100 1000 10000 100000
Transfer Size (KBytes)SCIF allows memory sharing via mmap(..) between processes on different PCIe nodes and thus provides bare-metal PCIe latency. The round trip SCIF mmap latency from the host to an x100 MIC for an 8 byte message is 0.44 usecs.
For more information on SCIF please refer to the Linux Con 2013 slides titled "Intel® MIC x100 Coprocessor Driver - on the Frontiers of Linux & HPC" at
http://events.linuxfoundation.org/sites/events/files/slides/LinuxConMicDriver.pdf
The talk can also be viewed at https://www.youtube.com/watch?v=dylbmmQs4W0
This initial patch series introduces the SCIF API and implements the SCIF connection, messaging and node enumeration APIs. SCIF poll, mmap, RDMA and fence APIs will be submitted in a future patch series once the initial base patches are accepted upstream.
This patch series is divided into 13 patches as follows:
1) SCIF header file documenting the API along with the IOCTL interface
2) SCIF ring buffer is a single producer, single consumer byte stream ring buffer optimized for avoiding reads across the PCIe bus. The ring buffer is used to implement a receive queue for SCIF driver messaging between nodes and for byte stream messaging between SCIF endpoints. Each SCIF node has a receive queue for every other SCIF node, and each connected endpoint has a receive queue for messages from its peer. This pair of receive queues is referred to as a SCIF queue pair.
3) SCIF hardware bus which abstracts the low level hardware details so that the same SCIF driver can work without any changes on the host or the card as long as the hardware bus operations are implemented.
4) SCIF peer bus is used to register and unregister SCIF peer devices internally by the SCIF driver to signify the addition and removal of peer nodes respectively from the SCIF network. This simplifies remote node handling within SCIF and will also be used to support device probe/remove for SCIF client drivers (e.g. netdev over SCIF)
5) Common MIC header file changes to enable SCIF
6) SCIF module initialization, DMA/remote memory mapping APIs and debugfs hooks.
7) SCIF node queue pair setup sets up the kernel mode private node queue pairs between all the nodes to enable internal control message communication.
8) SCIF character device file operations and kernel APIs for opening and closing a user and kernel mode SCIF endpoint. This patch also enables binding to a SCIF port and listening for incoming SCIF connections.
9) SCIF connection APIs which establish a SCIF connection between a pair of user or kernel mode endpoints.
10) SCIF messaging APIs which allow sending messages between the SCIF endpoints via a byte stream based ring buffer which has been optimized to avoid reads across PCIe. The node enumeration API enables a user to query for the number of online nodes.
11) MIC host driver specific changes to enable SCIF
12) MIC card driver specific changes to enable SCIF
13) Add support for loading/unloading SCIF driver
Nikhil Rao (1):
misc: mic: SCIF connections APIs i.e. accept and connect
Sudeep Dutt (12):
misc: mic: SCIF header file and IOCTL interface
misc: mic: SCIF ring buffer infrastructure
misc: mic: SCIF Hardware Bus
misc: mic: SCIF Peer Bus
misc: mic: Common MIC header file changes in preparation for SCIF
misc: mic: SCIF module initialization
misc: mic: SCIF node queue pair setup management
misc: mic: SCIF open close bind and listen APIs
misc: mic: SCIF messaging and node enumeration APIs
misc: mic: MIC host driver specific changes to enable SCIF
misc: mic: MIC card driver specific changes to enable SCIF
misc: mic: add support for loading/unloading SCIF driver
Documentation/mic/mic_overview.txt | 28 +- Documentation/mic/scif_overview.txt | 62 ++ drivers/misc/mic/Kconfig | 40 +- drivers/misc/mic/Makefile | 3 +- drivers/misc/mic/bus/Makefile | 1 + drivers/misc/mic/scif/Makefile | 15 + include/uapi/linux/Kbuild | 1 + drivers/misc/mic/bus/scif_bus.h | 129 ++++ drivers/misc/mic/card/mic_device.h | 11 +- drivers/misc/mic/card/mic_x100.h | 1 + drivers/misc/mic/common/mic_dev.h | 3 + drivers/misc/mic/host/mic_device.h | 11 +- drivers/misc/mic/host/mic_intr.h | 3 +- drivers/misc/mic/host/mic_smpt.h | 1 + drivers/misc/mic/scif/scif_epd.h | 160 ++++ drivers/misc/mic/scif/scif_main.h | 250 +++++++ drivers/misc/mic/scif/scif_map.h | 113 +++ drivers/misc/mic/scif/scif_nodeqp.h | 182 +++++ drivers/misc/mic/scif/scif_peer_bus.h | 63 ++ drivers/misc/mic/scif/scif_rb.h | 100 +++ include/linux/scif.h | 1132 ++++++++++++++++++++++++++++ include/uapi/linux/mic_common.h | 12 + include/uapi/linux/scif_ioctl.h | 233 ++++++ drivers/misc/mic/bus/scif_bus.c | 210 ++++++ drivers/misc/mic/card/mic_device.c | 132 +++- drivers/misc/mic/card/mic_x100.c | 61 +- drivers/misc/mic/host/mic_boot.c | 264 ++++++- drivers/misc/mic/host/mic_debugfs.c | 13 + drivers/misc/mic/host/mic_main.c | 6 + drivers/misc/mic/host/mic_smpt.c | 7 +- drivers/misc/mic/host/mic_virtio.c | 6 +- drivers/misc/mic/host/mic_x100.c | 3 +- drivers/misc/mic/scif/scif_api.c | 1270 ++++++++++++++++++++++++++++++++ drivers/misc/mic/scif/scif_debugfs.c | 82 +++ drivers/misc/mic/scif/scif_epd.c | 353 +++++++++ drivers/misc/mic/scif/scif_fd.c | 303 ++++++++ drivers/misc/mic/scif/scif_main.c | 395 ++++++++++ drivers/misc/mic/scif/scif_nm.c | 229 ++++++ drivers/misc/mic/scif/scif_nodeqp.c | 1303 +++++++++++++++++++++++++++++++++ drivers/misc/mic/scif/scif_peer_bus.c | 124 ++++ drivers/misc/mic/scif/scif_ports.c | 124 ++++ drivers/misc/mic/scif/scif_rb.c | 248 +++++++ Documentation/mic/mpssd/mpss | 23 +- 43 files changed, 7654 insertions(+), 56 deletions(-) create mode 100644 Documentation/mic/scif_overview.txt create mode 100644 drivers/misc/mic/scif/Makefile create mode 100644 drivers/misc/mic/bus/scif_bus.h create mode 100644 drivers/misc/mic/scif/scif_epd.h create mode 100644 drivers/misc/mic/scif/scif_main.h create mode 100644 drivers/misc/mic/scif/scif_map.h create mode 100644 drivers/misc/mic/scif/scif_nodeqp.h create mode 100644 drivers/misc/mic/scif/scif_peer_bus.h create mode 100644 drivers/misc/mic/scif/scif_rb.h create mode 100644 include/linux/scif.h create mode 100644 include/uapi/linux/scif_ioctl.h create mode 100644 drivers/misc/mic/bus/scif_bus.c create mode 100644 drivers/misc/mic/scif/scif_api.c create mode 100644 drivers/misc/mic/scif/scif_debugfs.c create mode 100644 drivers/misc/mic/scif/scif_epd.c create mode 100644 drivers/misc/mic/scif/scif_fd.c create mode 100644 drivers/misc/mic/scif/scif_main.c create mode 100644 drivers/misc/mic/scif/scif_nm.c create mode 100644 drivers/misc/mic/scif/scif_nodeqp.c create mode 100644 drivers/misc/mic/scif/scif_peer_bus.c create mode 100644 drivers/misc/mic/scif/scif_ports.c create mode 100644 drivers/misc/mic/scif/scif_rb.c
Signature · 1 line
1.8.2.1
PATCH 2/13 misc: mic: SCIF ring buffer infrastructure
SCIF ring buffer is a single producer, single consumer byte stream ring buffer optimized for avoiding reads across the PCIe bus. The ring buffer is used to implement a receive queue for SCIF driver messaging between nodes and for byte stream messaging between SCIF endpoints. Each SCIF node has a receive queue for every other SCIF node, and each connected endpoint has a receive queue for messages from its peer. This pair of receive queues is referred to as a SCIF queue pair.
--- drivers/misc/mic/scif/scif_rb.h | 100 ++++++++++++++++ drivers/misc/mic/scif/scif_rb.c | 248 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 348 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_rb.h create mode 100644 drivers/misc/mic/scif/scif_rb.c
drivers/misc/mic/scif/scif_rb.h new file +100 -0
@@ -0,0 +1,100 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* BSD LICENSE +* +* Copyright(c) 2014 Intel Corporation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Intel SCIF driver. +*/ +#ifndef SCIF_RB_H +#define SCIF_RB_H +/* +* This file describes a general purpose, byte based ring buffer. Writers to the +* ring buffer need to synchronize using a lock. The same is true for readers, +* although in practice, the ring buffer has a single reader. It is lockless +* between producer and consumer so it can handle being used across the PCIe +* bus. The ring buffer ensures that there are no reads across the PCIe bus for +* performance reasons. Two of these are used to form a single bidirectional +* queue-pair across PCIe. +*/ +/* +* struct scif_rb - SCIF Ring Buffer +* +* @rb_base: The base of the memory used for storing RB messages +* @read_ptr: Pointer to the read offset +* @write_ptr: Pointer to the write offset +* @size: Size of the memory in rb_base +* @current_read_offset: Cached read offset for performance +* @current_write_offset: Cached write offset for performance +*/ +struct scif_rb { +void *rb_base; +uint32_t *read_ptr; +uint32_t *write_ptr; +uint32_t size; +uint32_t current_read_offset; +uint32_t current_write_offset; +}; + +/* methods used by both */ +void scif_rb_init (struct scif_rb *rb,uint32_t *read_ptr,uint32_t *write_ptr, +void *rb_base,uint8_t size); +/* writer only methods */ +/* write a new command, then scif_rb_commit() */ +int scif_rb_write (struct scif_rb *rb,void *msg,uint32_t size); +/* after write(), then scif_rb_commit() */ +void scif_rb_commit (struct scif_rb *rb); +/* query space available for writing to a RB. */ +uint32_t scif_rb_space (struct scif_rb *rb); + +/* reader only methods */ +/* read a new message from the ring buffer of size bytes */ +uint32_t scif_rb_get_next (struct scif_rb *rb,void *msg,uint32_t size); +/* update the read pointer so that the space can be reused */ +void scif_rb_update_read_ptr (struct scif_rb *rb); +/* count the number of bytes that can be read */ +uint32_t scif_rb_count (struct scif_rb *rb,uint32_t size); +#endif
drivers/misc/mic/scif/scif_rb.c new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 13/13 misc: mic: add support for loading/unloading SCIF driver
In reply to Sudeep Duttmodprobe SCIF driver upon start and remove it upon unload
--- Documentation/mic/mpssd/mpss | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
Documentation/mic/mpssd/mpss +10 -13
@@ -48,18 +48,15 @@ start() fi echo -e $"Starting MPSS Stack" - echo -e $"Loading MIC_X100_DMA & MIC_HOST Modules" + echo -e $"Loading MIC_HOST, MIC_X100_DMA & SCIF Modules" - for f in "mic_host" "mic_x100_dma" - do - modprobe $f - RETVAL=$? - if [ $RETVAL -ne 0 ]; then - failure - echo - return $RETVAL - fi - done + modprobe -a mic_host mic_x100_dma scif + RETVAL=$? + if [ $RETVAL -ne 0 ]; then + failure + echo + return $RETVAL + fi # Start the daemon echo -n $"Starting MPSSD "
@@ -170,8 +167,8 @@ unload() stop sleep 5 - echo -n $"Removing MIC_HOST & MIC_X100_DMA Modules: " - modprobe -r mic_host mic_x100_dma + echo -n $"Removing SCIF, MIC_HOST & MIC_X100_DMA Modules: " + modprobe -r scif mic_host mic_x100_dma scif RETVAL=$? [ $RETVAL -ne 0 ] && failure || success echo
Signature · 1 line
1.8.2.1
PATCH 12/13 misc: mic: MIC card driver specific changes to enable SCIF
In reply to Sudeep DuttMIC card driver specific changes to enable SCIF. This patch implements the SCIF hardware bus operations and registers a SCIF device on the SCIF hardware bus.
--- drivers/misc/mic/Kconfig | 2 +- drivers/misc/mic/card/mic_device.h | 11 +++- drivers/misc/mic/card/mic_x100.h | 1 + drivers/misc/mic/card/mic_device.c | 132 ++++++++++++++++++++++++++++++++++++- drivers/misc/mic/card/mic_x100.c | 61 ++++++++++++++++- 5 files changed, 201 insertions(+), 6 deletions(-)
drivers/misc/mic/Kconfig +1 -1
@@ -56,7 +56,7 @@ comment "Intel MIC Card Driver" config INTEL_MIC_CARD tristate "Intel MIC Card Driver" - depends on 64BIT && X86 && INTEL_MIC_BUS + depends on 64BIT && X86 && INTEL_MIC_BUS && SCIF_BUS select VIRTIO help This enables card driver support for the Intel Many Integrated
drivers/misc/mic/card/mic_device.h +9 -2
@@ -29,9 +29,9 @@#include <linux/workqueue.h> #include <linux/io.h> -#include <linux/irqreturn.h> #include <linux/interrupt.h> #include <linux/mic_bus.h> +#include "../bus/scif_bus.h" /** * struct mic_intr_info - Contains h/w specific interrupt sources info
@@ -73,6 +73,9 @@ struct mic_device {* @irq_info: The OS specific irq information * @intr_info: H/W specific interrupt information. * @dma_mbdev: dma device on the MIC virtual bus. +* @dma_ch - Array of DMA channels +* @num_dma_ch - Number of DMA channels available +* @scdev: SCIF device on the SCIF virtual bus. */ struct mic_driver {char name[20 ];
@@ -84,6 +87,9 @@ struct mic_driver {struct mic_irq_info irq_info;struct mic_intr_info intr_info;struct mbus_device *dma_mbdev; +struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN ]; +int num_dma_ch; +struct scif_hw_dev *scdev; };/**
@@ -122,10 +128,11 @@ void mic_driver_uninit(struct mic_driver *mdrv);int mic_next_card_db (void );struct mic_irq *mic_request_card_irq (irq_handler_t handler,irq_handler_t thread_fn, -const char *name,void *data,int intr_src); +const char *name,void *data,int db);void mic_free_card_irq (struct mic_irq *cookie,void *data);u32 mic_read_spad (struct mic_device *mdev,unsigned int idx);void mic_send_intr (struct mic_device *mdev,int doorbell); +void mic_send_p2p_intr (int doorbell,struct mic_mw *mw);int mic_db_to_irq (struct mic_driver *mdrv,int db);u32 mic_ack_interrupt (struct mic_device *mdev);void mic_hw_intr_init (struct mic_driver *mdrv);
drivers/misc/mic/card/mic_x100.h +1 -0
@@ -35,6 +35,7 @@#define MIC_X100_SBOX_SDBIC0 0x0000CC90#define MIC_X100_SBOX_SDBIC0_DBREQ_BIT 0x80000000#define MIC_X100_SBOX_RDMASR0 0x0000B180 +#define MIC_X100_SBOX_APICICR0 0x0000A9D0#define MIC_X100_MAX_DOORBELL_IDX 8
drivers/misc/mic/card/mic_device.c +131 -1
169 lines not on this page · raw message
drivers/misc/mic/card/mic_x100.c +59 -2
92 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 5/13 misc: mic: Common MIC header file changes in preparation for SCIF
In reply to Sudeep Dutt--- drivers/misc/mic/common/mic_dev.h | 3 +++ include/uapi/linux/mic_common.h | 12 ++++++++++++ 2 files changed, 15 insertions(+)
drivers/misc/mic/common/mic_dev.h +3 -0
@@ -48,4 +48,7 @@ struct mic_mw {#define MIC_VIRTIO_PARAM_DEV_REMOVE 0x1#define MIC_VIRTIO_PARAM_CONFIG_CHANGED 0x2 +/* Maximum number of DMA channels */ +#define MIC_MAX_DMA_CHAN 4 +#endif
include/uapi/linux/mic_common.h +12 -0
@@ -80,6 +80,12 @@ struct mic_device_ctrl {* @h2c_config_db: Host to Card Virtio config doorbell set by card * @shutdown_status: Card shutdown status set by card * @shutdown_card: Set to 1 by the host when a card shutdown is initiated +* @tot_nodes: Total number of nodes in the SCIF network +* @node_id: Unique id of the node +* @h2c_scif_db - Host to card SCIF doorbell set by card +* @c2h_scif_db - Card to host SCIF doorbell set by host +* @scif_host_dma_addr - SCIF host queue pair DMA address +* @scif_card_dma_addr - SCIF card queue pair DMA address */ struct mic_bootparam {__le32 magic;
@@ -88,6 +94,12 @@ struct mic_bootparam {__s8 h2c_config_db;__u8 shutdown_status;__u8 shutdown_card; +__u8 tot_nodes; +__u8 node_id; +__u8 h2c_scif_db; +__u8 c2h_scif_db; +__u64 scif_host_dma_addr; +__u64 scif_card_dma_addr; } __attribute__ ((aligned(8)));/**
Signature · 1 line
1.8.2.1
PATCH 9/13 misc: mic: SCIF connections APIs i.e. accept and connect
In reply to Sudeep DuttFrom: Nikhil Rao <[email protected]>
SCIF connection APIs which establish a SCIF connection between a pair of SCIF endpoints. A SCIF connection consists of a dedicated queue-pair between the endpoints. Client messages are sent over the queue-pair whereas the signaling associated with the message is multiplexed over the node queue-pair. Similarly other control messages such as exposing registered memory are also sent over the node queue-pair. The SCIF endpoints must be in connected state to exchange messages, register memory, map remote memory and trigger DMA transfers. SCIF connections can be set up asynchronously or synchronously.
Thanks to Johnnie S Peters for authoring parts of this patch during early bring up of the SCIF driver.
--- drivers/misc/mic/scif/scif_epd.h | 8 + drivers/misc/mic/scif/scif_api.c | 455 ++++++++++++++++++++++++++++++++++++ drivers/misc/mic/scif/scif_epd.c | 229 ++++++++++++++++++ drivers/misc/mic/scif/scif_fd.c | 106 +++++++++ drivers/misc/mic/scif/scif_main.c | 1 + drivers/misc/mic/scif/scif_nm.c | 36 +++ drivers/misc/mic/scif/scif_nodeqp.c | 16 +- 7 files changed, 850 insertions(+), 1 deletion(-)
drivers/misc/mic/scif/scif_epd.h +8 -0
@@ -144,5 +144,13 @@ int scif_rsrv_port(u16 port);void scif_get_port (u16 port);int scif_get_new_port (void );void scif_put_port (u16 port); +void scif_cnctreq (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_cnctgnt (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_cnctgnt_ack (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_cnctgnt_nack (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_cnctrej (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_discnct (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_discnt_ack (struct scif_dev *scifdev,struct scifmsg *msg); +int __scif_connect (scif_epd_t epd,struct scif_port_id *dst,bool non_block);int __scif_flush (scif_epd_t epd);#endif /* SCIF_EPD_H */
drivers/misc/mic/scif/scif_api.c +455 -0
458 lines not on this page · raw message
drivers/misc/mic/scif/scif_epd.c +229 -0
238 lines not on this page · raw message
drivers/misc/mic/scif/scif_fd.c +106 -0
118 lines not on this page · raw message
drivers/misc/mic/scif/scif_main.c +1 -0
@@ -334,6 +334,7 @@ static int _scif_init(void) scif_info.en_msg_log =0 ; scif_info.p2p_enable =1 ;INIT_WORK (&scif_info.misc_work, scif_misc_handler); +INIT_WORK (&scif_info.conn_work, scif_conn_handler);idr_init (&scif_ports);return 0 ; }
drivers/misc/mic/scif/scif_nm.c +36 -0
@@ -20,6 +20,41 @@#include "scif_main.h" #include "scif_map.h" +/** +* scif_invalidate_ep() - Set state for all connected endpoints +* to disconnected and wake up all send/recv waitqueues +*/ +static void scif_invalidate_ep (int node) +{ +struct scif_endpt *ep; +struct list_head *pos, *tmpq; + +flush_work (&scif_info.conn_work); +mutex_lock (&scif_info.connlock); +list_for_each_safe (pos, tmpq, &scif_info.disconnected) { + ep = list_entry(pos, struct scif_endpt, list); +if (ep->remote_dev->node == node) { +spin_lock (&ep->lock); +scif_cleanup_ep_qp (ep); +spin_unlock (&ep->lock); + } + } +list_for_each_safe (pos, tmpq, &scif_info.connected) { + ep = list_entry(pos, struct scif_endpt, list); +if (ep->remote_dev->node == node) { +list_del (pos); +spin_lock (&ep->lock); + ep->state =SCIFEP_DISCONNECTED ; +list_add_tail (&ep->list, &scif_info.disconnected); +scif_cleanup_ep_qp (ep); +wake_up_interruptible (&ep->sendwq); +wake_up_interruptible (&ep->recvwq); +spin_unlock (&ep->lock); + } + } +mutex_unlock (&scif_info.connlock); +} +void scif_free_qp (struct scif_dev *scifdev) {struct scif_qp *qp = scifdev->qpairs;
@@ -91,6 +126,7 @@ void scif_cleanup_scifdev(struct scif_dev *dev)scif_destroy_intr_wq (dev); }scif_destroy_p2p (dev); +scif_invalidate_ep (dev->node);scif_send_acks (dev);scif_cleanup_qp (dev); }
drivers/misc/mic/scif/scif_nodeqp.c +15 -1
@@ -580,7 +580,14 @@ static char *message_types[] = {"BAD","SCIF_NODE_ADD_ACK" ,"SCIF_NODE_ADD_NACK" ,"REMOVE_NODE" , - "REMOVE_NODE_ACK"}; +"REMOVE_NODE_ACK" , +"CNCT_REQ" , +"CNCT_GNT" , +"CNCT_GNTACK" , +"CNCT_GNTNACK" , +"CNCT_REJ" , +"DISCNCT" , + "DISCNT_ACK"}; static void scif_display_message(struct scif_dev *scifdev, struct scifmsg *msg,
@@ -956,6 +963,13 @@ static void (*scif_intr_func[SCIF_MAX_MSG + 1]) scif_node_add_nack,/* SCIF_NODE_ADD_NACK */ scif_node_remove,/* SCIF_NODE_REMOVE */ scif_node_remove_ack,/* SCIF_NODE_REMOVE_ACK */ + scif_cnctreq,/* SCIF_CNCT_REQ */ + scif_cnctgnt,/* SCIF_CNCT_GNT */ + scif_cnctgnt_ack,/* SCIF_CNCT_GNTACK */ + scif_cnctgnt_nack,/* SCIF_CNCT_GNTNACK */ + scif_cnctrej,/* SCIF_CNCT_REJ */ + scif_discnct,/* SCIF_DISCNCT */ + scif_discnt_ack, /* SCIF_DISCNT_ACK */ };/**
Signature · 1 line
1.8.2.1
PATCH 10/13 misc: mic: SCIF messaging and node enumeration APIs
In reply to Sudeep DuttSCIF messaging APIs which allow sending messages between the SCIF endpoints via a byte stream based ring buffer which has been optimized to avoid reads across PCIe. The SCIF messaging APIs are typically used for short < 1024 byte messages for best performance while the RDMA APIs which will be submitted in a future patch series is recommended for larger transfers. The node enumeration API enables a user to query for the number of nodes online in the SCIF network and their node ids.
--- drivers/misc/mic/scif/scif_epd.h | 4 + drivers/misc/mic/scif/scif_api.c | 398 ++++++++++++++++++++++++++++++++++++ drivers/misc/mic/scif/scif_epd.c | 32 +++ drivers/misc/mic/scif/scif_fd.c | 93 +++++++++ drivers/misc/mic/scif/scif_nm.c | 17 ++ drivers/misc/mic/scif/scif_nodeqp.c | 36 +++- 6 files changed, 579 insertions(+), 1 deletion(-)
drivers/misc/mic/scif/scif_epd.h +4 -0
@@ -144,6 +144,8 @@ int scif_rsrv_port(u16 port);void scif_get_port (u16 port);int scif_get_new_port (void );void scif_put_port (u16 port); +int scif_user_send (scif_epd_t epd,void __user *msg,int len,int flags); +int scif_user_recv (scif_epd_t epd,void __user *msg,int len,int flags);void scif_cnctreq (struct scif_dev *scifdev,struct scifmsg *msg);void scif_cnctgnt (struct scif_dev *scifdev,struct scifmsg *msg);void scif_cnctgnt_ack (struct scif_dev *scifdev,struct scifmsg *msg);
@@ -151,6 +153,8 @@ void scif_cnctgnt_nack(struct scif_dev *scifdev, struct scifmsg *msg);void scif_cnctrej (struct scif_dev *scifdev,struct scifmsg *msg);void scif_discnct (struct scif_dev *scifdev,struct scifmsg *msg);void scif_discnt_ack (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_clientsend (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_clientrcvd (struct scif_dev *scifdev,struct scifmsg *msg);int __scif_connect (scif_epd_t epd,struct scif_port_id *dst,bool non_block);int __scif_flush (scif_epd_t epd);#endif /* SCIF_EPD_H */
drivers/misc/mic/scif/scif_api.c +398 -0
401 lines not on this page · raw message
drivers/misc/mic/scif/scif_epd.c +32 -0
@@ -319,3 +319,35 @@ void scif_discnt_ack(struct scif_dev *scifdev, struct scifmsg *msg)spin_unlock (&ep->lock);complete (&ep->discon); } + +/** +* scif_clientsend() - Respond to SCIF_CLIENT_SEND interrupt message +* @msg: Interrupt message +* +* Remote side is confirming send or receive interrupt handling is complete. +*/ +void scif_clientsend (struct scif_dev *scifdev,struct scifmsg *msg) +{ +struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0 ]; + +spin_lock (&ep->lock); +if (SCIFEP_CONNECTED == ep->state) +wake_up_interruptible (&ep->recvwq); +spin_unlock (&ep->lock); +} + +/** +* scif_clientrcvd() - Respond to SCIF_CLIENT_RCVD interrupt message +* @msg: Interrupt message +* +* Remote side is confirming send or receive interrupt handling is complete. +*/ +void scif_clientrcvd (struct scif_dev *scifdev,struct scifmsg *msg) +{ +struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0 ]; + +spin_lock (&ep->lock); +if (SCIFEP_CONNECTED == ep->state) +wake_up_interruptible (&ep->sendwq); +spin_unlock (&ep->lock); +}
drivers/misc/mic/scif/scif_fd.c +93 -0
105 lines not on this page · raw message
drivers/misc/mic/scif/scif_nm.c +17 -0
@@ -210,3 +210,20 @@ void scif_disconnect_node(u32 node_id, bool mgmt_initiated) (atomic_read (&scifdev->disconn_rescnt) ==1 ), SCIF_NODE_ALIVE_TIMEOUT); } + +void scif_get_node_info (void ) +{ +struct scifmsg msg; +DECLARE_COMPLETION_ONSTACK (node_info); + + msg.uop =SCIF_GET_NODE_INFO ; + msg.src.node = scif_info.nodeid; + msg.dst.node =SCIF_MGMT_NODE ; + msg.payload[3 ] = (u64)&node_info; + +if ((scif_nodeqp_send (&scif_dev[SCIF_MGMT_NODE ], &msg))) +return ; + +/* Wait for a response with SCIF_GET_NODE_INFO */ +wait_for_completion (&node_info); +}
drivers/misc/mic/scif/scif_nodeqp.c +35 -1
@@ -587,7 +587,10 @@ static char *message_types[] = {"BAD","CNCT_GNTNACK" ,"CNCT_REJ" ,"DISCNCT" , - "DISCNT_ACK"}; +"DISCNT_ACK" , +"CLIENT_SENT" , +"CLIENT_RCVD" , + "SCIF_GET_NODE_INFO"}; static void scif_display_message(struct scif_dev *scifdev, struct scifmsg *msg,
@@ -944,6 +947,34 @@ scif_node_remove_ack(struct scif_dev *scifdev, struct scifmsg *msg)wake_up (&sdev->disconn_wq); } +/** +* scif_get_node_info: Respond to SCIF_GET_NODE_INFO interrupt message +* @msg: Interrupt message +* +* Retrieve node info i.e maxid and total from the mgmt node. +*/ +static __always_inline void +scif_get_node_info_resp (struct scif_dev *scifdev,struct scifmsg *msg) +{ +if (scif_is_mgmt_node ()) { +swap (msg->dst.node, msg->src.node); +mutex_lock (&scif_info.conflock); + msg->payload[1 ] = scif_info.maxid; + msg->payload[2 ] = scif_info.total; +mutex_unlock (&scif_info.conflock); +scif_nodeqp_send (scifdev, msg); + }else { +struct completion *node_info = + (struct completion *)msg->payload[3 ]; + +mutex_lock (&scif_info.conflock); + scif_info.maxid = msg->payload[1 ]; + scif_info.total = msg->payload[2 ]; +complete_all (node_info); +mutex_unlock (&scif_info.conflock); + } +} +static void scif_msg_unknown (struct scif_dev *scifdev,struct scifmsg *msg) {
@@ -970,6 +1001,9 @@ static void (*scif_intr_func[SCIF_MAX_MSG + 1]) scif_cnctrej,/* SCIF_CNCT_REJ */ scif_discnct,/* SCIF_DISCNCT */ scif_discnt_ack,/* SCIF_DISCNT_ACK */ + scif_clientsend,/* SCIF_CLIENT_SENT */ + scif_clientrcvd,/* SCIF_CLIENT_RCVD */ + scif_get_node_info_resp,/* SCIF_GET_NODE_INFO */ };/**
Signature · 1 line
1.8.2.1
PATCH 4/13 misc: mic: SCIF Peer Bus
In reply to Sudeep DuttThe SCIF peer bus is used to register and unregister SCIF peer devices internally by the SCIF driver to signify the addition and removal of peer nodes respectively from the SCIF network. This simplifies remote node handling within SCIF and will also be used to support device probe/remove for SCIF client drivers (e.g. netdev over SCIF)
--- drivers/misc/mic/scif/scif_peer_bus.h | 63 +++++++++++++++++ drivers/misc/mic/scif/scif_peer_bus.c | 124 ++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_peer_bus.h create mode 100644 drivers/misc/mic/scif/scif_peer_bus.c
drivers/misc/mic/scif/scif_peer_bus.h new file +63 -0
@@ -0,0 +1,63 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* Intel SCIF driver. +*/ +#ifndef _SCIF_PEER_BUS_H_ +#define _SCIF_PEER_BUS_H_ + +#include <linux/device.h> +#include <linux/mic_common.h> + +/* +* Peer devices show up as PCIe devices for the mgmt node but not the cards. +* The mgmt node discovers all the cards on the PCIe bus and informs the other +* cards about their peers. Upon notification of a peer a node adds a peer +* device to the peer bus to maintain symmetry in the way devices are +* discovered across all nodes in the SCIF network. +*/ +/** +* scif_peer_dev - representation of a peer SCIF device +* @dev: underlying device +* @dnode - The destination node which this device will communicate with. +*/ +struct scif_peer_dev { +struct device dev; +u8 dnode; +}; + +/** +* scif_peer_driver - operations for a scif_peer I/O driver +* @driver: underlying device driver (populate name and owner). +* @id_table: the ids serviced by this driver. +* @probe: the function to call when a device is found. Returns 0 or -errno. +* @remove: the function to call when a device is removed. +*/ +struct scif_peer_driver { +struct device_driver driver; +const struct scif_peer_dev_id *id_table; + +int (*probe)(struct scif_peer_dev *dev); +void (*remove)(struct scif_peer_dev *dev); +}; + +int scif_peer_register_driver (struct scif_peer_driver *driver); +void scif_peer_unregister_driver (struct scif_peer_driver *driver); +struct scif_dev ; +struct scif_peer_dev * +scif_peer_register_device (struct scif_dev *sdev); +void scif_peer_unregister_device (struct scif_peer_dev *sdev); +int scif_peer_bus_init (void ); +void scif_peer_bus_exit (void ); +#endif /* _SCIF_PEER_BUS_H */
drivers/misc/mic/scif/scif_peer_bus.c new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 7/13 misc: mic: SCIF node queue pair setup management
In reply to Sudeep DuttSCIF node queue pair setup creates the SCIF driver kernel mode private node queue pairs between all the nodes to enable internal control message communication once SCIF gets probed by the SCIF hardware bus. Peer to peer communication between MIC Coprocessor nodes is supported.
--- drivers/misc/mic/scif/scif_nodeqp.h | 172 +++++ drivers/misc/mic/scif/scif_nm.c | 176 +++++ drivers/misc/mic/scif/scif_nodeqp.c | 1255 +++++++++++++++++++++++++++++++++++ 3 files changed, 1603 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_nodeqp.h create mode 100644 drivers/misc/mic/scif/scif_nm.c create mode 100644 drivers/misc/mic/scif/scif_nodeqp.c
drivers/misc/mic/scif/scif_nodeqp.h new file +172 -0
@@ -0,0 +1,172 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* BSD LICENSE +* +* Copyright(c) 2014 Intel Corporation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Intel SCIF driver. +* +*/ +#ifndef SCIF_NODEQP +#define SCIF_NODEQP + +#include "scif_rb.h" +#include "scif_peer_bus.h" + +#define SCIF_INIT 1/* First message sent to the peer node for discovery */ +#define SCIF_EXIT 2/* Last message from the peer informing intent to exit */ +#define SCIF_EXIT_ACK 3/* Response to SCIF_EXIT message */ +#define SCIF_NODE_ADD 4/* Tell Online nodes a new node exits */ +#define SCIF_NODE_ADD_ACK 5/* Confirm to mgmt node sequence is finished */ +#define SCIF_NODE_ADD_NACK 6/* SCIF_NODE_ADD failed */ +#define SCIF_NODE_REMOVE 7/* Request to deactivate a SCIF node */ +#define SCIF_NODE_REMOVE_ACK 8/* Response to a SCIF_NODE_REMOVE message */ +#define SCIF_MAX_MSG SCIF_NODE_REMOVE_ACK + +/* +* struct scifmsg - Node QP message format +* +* @src: Source information +* @dst: Destination information +* @uop: The message opcode +* @payload: Unique payload format for each message +*/ +struct scifmsg { +struct scif_port_id src; +struct scif_port_id dst; +uint32_t uop; +uint64_t payload[4 ]; +} __packed; + +/* +* struct scif_qp - Node Queue Pair +* +* Interesting structure -- a little difficult because we can only +* write across the PCIe, so any r/w pointer we need to read is +* local. We only need to read the read pointer on the inbound_q +* and read the write pointer in the outbound_q +* +* @magic: Magic value to ensure the peer sees the QP correctly +* @outbound_q: The outbound ring buffer for sending messages +* @inbound_q: The inbound ring buffer for receiving messages +* @local_write: Local write index +* @local_read: Local read index +* @remote_qp: The remote queue pair +* @local_buf: DMA address of local ring buffer +* @local_qp: DMA address of the local queue pair data structure +* @remote_buf: DMA address of remote ring buffer +* @qp_state: QP state i.e. online or offline used for P2P +* @send_lock: synchronize access to outbound queue +* @recv_lock: Synchronize access to inbound queue +*/ +struct scif_qp { +uint64_t magic; +#define SCIFEP_MAGIC 0x5c1f000000005c1fULL +struct scif_rb outbound_q; +struct scif_rb inbound_q; + +uint32_t local_write__aligned(64) ; +uint32_t local_read__aligned(64) ; +struct scif_qp *remote_qp; +dma_addr_t local_buf; +dma_addr_t local_qp; +dma_addr_t remote_buf; +uint32_t qp_state; +#define SCIF_QP_OFFLINE 0xdead +#define SCIF_QP_ONLINE 0xc0de +spinlock_t send_lock; +spinlock_t recv_lock; +}; + +/* +* struct scif_loopb_msg - An element in the loopback Node QP message list. +* +* @msg - The SCIF node QP message +* @list - link in the list of messages +*/ +struct scif_loopb_msg { +struct scifmsg msg; +struct list_head list; +}; + +int scif_nodeqp_send (struct scif_dev *scifdev,struct scifmsg *msg); +int _scif_nodeqp_send (struct scif_dev *scifdev,struct scifmsg *msg); +void scif_nodeqp_intrhandler (struct scif_dev *scifdev,struct scif_qp *qp); +int scif_loopb_msg_handler (struct scif_dev *scifdev,struct scif_qp *qp); +int scif_setup_qp (struct scif_dev *scifdev); +int scif_qp_response (phys_addr_t phys,struct scif_dev *dev); +int scif_setup_qp_connect (struct scif_qp *qp,dma_addr_t *qp_offset, +int local_size,struct scif_dev *scifdev); +int scif_setup_qp_accept (struct scif_qp *qp,dma_addr_t *qp_offset, +dma_addr_t phys,int local_size, +struct scif_dev *scifdev); +int scif_setup_qp_connect_response (struct scif_dev *scifdev, +struct scif_qp *qp,u64 payload); +int scif_setup_loopback_qp (struct scif_dev *scifdev); +int scif_destroy_loopback_qp (struct scif_dev *scifdev); +void scif_poll_qp_state (struct work_struct *work); +void scif_destroy_p2p (struct scif_dev *scifdev); +void scif_send_exit (struct scif_dev *scifdev); +static inline struct device *scif_get_peer_dev (struct scif_dev *scifdev) +{ +struct scif_peer_dev *spdev; +struct device *spdev_ret; + +rcu_read_lock (); + spdev =rcu_dereference (scifdev->spdev); +if (spdev) + spdev_ret =get_device (&spdev->dev); +else + spdev_ret =ERR_PTR (-ENODEV ); +rcu_read_unlock (); +return spdev_ret; +} + +static inline void scif_put_peer_dev (struct device *dev) +{ +put_device (dev); +} +#endif /* SCIF_NODEQP */
drivers/misc/mic/scif/scif_nm.c new file +176 -0
176 lines not on this page · raw message
drivers/misc/mic/scif/scif_nodeqp.c new file +1255 -0
1,255 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 8/13 misc: mic: SCIF open close bind and listen APIs
In reply to Sudeep DuttSCIF character device file operations and kernel APIs for opening and closing a user and kernel mode SCIF endpoint. This patch also enables binding to a SCIF port and listening for incoming SCIF connections.
--- drivers/misc/mic/Kconfig | 19 ++ drivers/misc/mic/Makefile | 1 + drivers/misc/mic/scif/Makefile | 15 ++ drivers/misc/mic/scif/scif_epd.h | 148 +++++++++++++ drivers/misc/mic/scif/scif_main.h | 2 + drivers/misc/mic/scif/scif_nodeqp.h | 12 +- drivers/misc/mic/scif/scif_api.c | 417 ++++++++++++++++++++++++++++++++++++ drivers/misc/mic/scif/scif_epd.c | 92 ++++++++ drivers/misc/mic/scif/scif_fd.c | 104 +++++++++ drivers/misc/mic/scif/scif_ports.c | 124 +++++++++++ 10 files changed, 933 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/mic/scif/Makefile create mode 100644 drivers/misc/mic/scif/scif_epd.h create mode 100644 drivers/misc/mic/scif/scif_api.c create mode 100644 drivers/misc/mic/scif/scif_epd.c create mode 100644 drivers/misc/mic/scif/scif_fd.c create mode 100644 drivers/misc/mic/scif/scif_ports.c
drivers/misc/mic/Kconfig +19 -0
@@ -69,3 +69,22 @@ config INTEL_MIC_CARD For more information see <http://software.intel.com/en-us/mic-developer>. + +comment "SCIF Driver" + +config SCIF + tristate "SCIF Driver" + depends on 64BIT && PCI && X86 && SCIF_BUS + help + This enables SCIF Driver support for the Intel Many Integrated + Core (MIC) family of PCIe form factor coprocessor devices that + run a 64 bit Linux OS. The Symmetric Communication Interface + (SCIF (pronounced as skiff)) is a low level communications API + across PCIe currently implemented for MIC. + + If you are building a host kernel with an Intel MIC device then + say M (recommended) or Y, else say N. If unsure say N. + + More information about the Intel MIC family as well as the Linux + OS and tools for MIC to use with this driver are available from + <http://software.intel.com/en-us/mic-developer>.
drivers/misc/mic/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_INTEL_MIC_HOST) += host/ obj-$(CONFIG_INTEL_MIC_CARD) += card/ obj-y += bus/ +obj-$(CONFIG_SCIF) += scif/
drivers/misc/mic/scif/Makefile new file +15 -0
@@ -0,0 +1,15 @@ +# +# Makefile - SCIF driver. +# Copyright(c) 2014, Intel Corporation. +# +obj-$(CONFIG_SCIF) += scif.o +scif-objs := scif_main.o +scif-objs += scif_peer_bus.o +scif-objs += scif_ports.o +scif-objs += scif_debugfs.o +scif-objs += scif_fd.o +scif-objs += scif_api.o +scif-objs += scif_epd.o +scif-objs += scif_rb.o +scif-objs += scif_nodeqp.o +scif-objs += scif_nm.o
drivers/misc/mic/scif/scif_epd.h new file +148 -0
148 lines not on this page · raw message
drivers/misc/mic/scif/scif_main.h +2 -0
@@ -234,6 +234,8 @@ static inline int _scifdev_alive(struct scif_dev *scifdev)return !!spdev; } +#include "scif_epd.h" +void __init scif_init_debugfs (void );void scif_exit_debugfs (void );int scif_setup_intr_wq (struct scif_dev *scifdev);
drivers/misc/mic/scif/scif_nodeqp.h +11 -1
@@ -64,7 +64,17 @@#define SCIF_NODE_ADD_NACK 6/* SCIF_NODE_ADD failed */ #define SCIF_NODE_REMOVE 7/* Request to deactivate a SCIF node */ #define SCIF_NODE_REMOVE_ACK 8/* Response to a SCIF_NODE_REMOVE message */ -#define SCIF_MAX_MSG SCIF_NODE_REMOVE_ACK +#define SCIF_CNCT_REQ 9/* Phys addr of Request connection to a port */ +#define SCIF_CNCT_GNT 10/* Phys addr of new Grant connection request */ +#define SCIF_CNCT_GNTACK 11/* Error type Reject a connection request */ +#define SCIF_CNCT_GNTNACK 12/* Error type Reject a connection request */ +#define SCIF_CNCT_REJ 13/* Error type Reject a connection request */ +#define SCIF_DISCNCT 14/* Notify peer that connection is being terminated */ +#define SCIF_DISCNT_ACK 15/* Notify peer that connection is being terminated */ +#define SCIF_CLIENT_SENT 16/* Notify the peer that data has been written */ +#define SCIF_CLIENT_RCVD 17/* Notify the peer that data has been read */ +#define SCIF_GET_NODE_INFO 18/* Get current node mask from the mgmt node*/ +#define SCIF_MAX_MSG SCIF_GET_NODE_INFO/* * struct scifmsg - Node QP message format
drivers/misc/mic/scif/scif_api.c new file +417 -0
417 lines not on this page · raw message
drivers/misc/mic/scif/scif_epd.c new file +92 -0
92 lines not on this page · raw message
drivers/misc/mic/scif/scif_fd.c new file +104 -0
104 lines not on this page · raw message
drivers/misc/mic/scif/scif_ports.c new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 3/13 misc: mic: SCIF Hardware Bus
In reply to Sudeep DuttThe SCIF hardware bus abstracts the low level hardware driver details like interrupts and mapping remote memory so that the same SCIF driver can work without any changes with the MIC host or card driver as long as the hardware bus operations are implemented. The SCIF hardware device is registered by the host and card drivers on the SCIF hardware bus resulting in probing the SCIF driver.
--- drivers/misc/mic/Kconfig | 17 ++++ drivers/misc/mic/Makefile | 2 +- drivers/misc/mic/bus/Makefile | 1 + drivers/misc/mic/bus/scif_bus.h | 129 ++++++++++++++++++++++++ drivers/misc/mic/bus/scif_bus.c | 210 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/mic/bus/scif_bus.h create mode 100644 drivers/misc/mic/bus/scif_bus.c
drivers/misc/mic/Kconfig +17 -0
@@ -15,6 +15,23 @@ config INTEL_MIC_BUS OS and tools for MIC to use with this driver are available from <http://software.intel.com/en-us/mic-developer>. +comment "SCIF Bus Driver" + +config SCIF_BUS + tristate "SCIF Bus Driver" + depends on 64BIT && PCI && X86 && X86_DEV_DMA_OPS + help + This option is selected by any driver which registers a + device or driver on the SCIF Bus, such as CONFIG_INTEL_MIC_HOST + and CONFIG_INTEL_MIC_CARD. + + If you are building a host/card kernel with an Intel MIC device + then say M (recommended) or Y, else say N. If unsure say N. + + More information about the Intel MIC family as well as the Linux + OS and tools for MIC to use with this driver are available from + <http://software.intel.com/en-us/mic-developer>. + comment "Intel MIC Host Driver" config INTEL_MIC_HOST
drivers/misc/mic/Makefile +1 -1
@@ -4,4 +4,4 @@ # obj-$(CONFIG_INTEL_MIC_HOST) += host/ obj-$(CONFIG_INTEL_MIC_CARD) += card/ -obj-$(CONFIG_INTEL_MIC_BUS) += bus/ +obj-y += bus/
drivers/misc/mic/bus/Makefile +1 -0
@@ -3,3 +3,4 @@ # Copyright(c) 2014, Intel Corporation. # obj-$(CONFIG_INTEL_MIC_BUS) += mic_bus.o +obj-$(CONFIG_SCIF_BUS) += scif_bus.o
drivers/misc/mic/bus/scif_bus.h new file +129 -0
129 lines not on this page · raw message
drivers/misc/mic/bus/scif_bus.c new file +210 -0
210 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 6/13 misc: mic: SCIF module initialization
In reply to Sudeep DuttSCIF module initialization, DMA mapping, ioremap wrapper APIs and debugfs hooks. SCIF gets probed by the SCIF hardware bus if SCIF devices were registered by base drivers. A MISC device is registered to provide the SCIF character device interface.
--- drivers/misc/mic/scif/scif_main.h | 248 ++++++++++++++++++++++ drivers/misc/mic/scif/scif_map.h | 113 ++++++++++ drivers/misc/mic/scif/scif_debugfs.c | 82 ++++++++ drivers/misc/mic/scif/scif_main.c | 394 +++++++++++++++++++++++++++++++++++ 4 files changed, 837 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_main.h create mode 100644 drivers/misc/mic/scif/scif_map.h create mode 100644 drivers/misc/mic/scif/scif_debugfs.c create mode 100644 drivers/misc/mic/scif/scif_main.c
drivers/misc/mic/scif/scif_main.h new file +248 -0
@@ -0,0 +1,248 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* Intel SCIF driver. +* +*/ +#ifndef SCIF_MAIN_H +#define SCIF_MAIN_H + +#include <linux/sched.h> +#include <linux/pci.h> +#include <linux/miscdevice.h> +#include <linux/dmaengine.h> +#include <linux/file.h> +#include <linux/scif.h> + +#include "../common/mic_dev.h" + +#define SCIF_MGMT_NODE 0 +#define SCIF_DEFAULT_WATCHDOG_TO 30 +#define SCIF_NODE_ACCEPT_TIMEOUT (3 * HZ) +#define SCIF_NODE_ALIVE_TIMEOUT (SCIF_DEFAULT_WATCHDOG_TO * HZ) + +/* +* Generic state used for certain node QP message exchanges +* like Unregister, Alloc etc. +*/ +enum scif_msg_state { +OP_IDLE =1 , +OP_IN_PROGRESS , +OP_COMPLETED , +OP_FAILED +}; + +/* +* struct scif_info - Global SCIF information +* +* @nodeid: Node ID this node is to others +* @maxid: Max known node ID +* @total: Total number of SCIF nodes +* @nr_zombies: number of zombie endpoints +* @eplock: Lock to synchronize listening, zombie endpoint lists +* @connlock: Lock to synchronize connected and disconnected lists +* @nb_connect_lock: Synchronize non blocking connect operations +* @port_lock: Synchronize access to SCIF ports +* @uaccept: List of user acceptreq waiting for acceptreg +* @listen: List of listening end points +* @zombie: List of zombie end points with pending RMA's +* @connected: List of end points in connected state +* @disconnected: List of end points in disconnected state +* @nb_connect_list: List for non blocking connections +* @misc_work: miscellaneous SCIF tasks +* @conflock: Lock to synchronize SCIF node configuration changes +* @en_msg_log: Enable debug message logging +* @p2p_enable: Enable P2P SCIF network +* @miscdev: The MISC device +* @conn_work: Work for workqueue handling all connections +* @exitwq: Wait queue for waiting for an EXIT node QP message response +* @loopb_dev: Dummy SCIF device used for loopback +* @loopb_wq: Workqueue used for handling loopback messages +* @loopb_wqname[16]: Name of loopback workqueue +* @loopb_work: Used for submitting work to loopb_wq +* @loopb_recv_q: List of messages received on the loopb_wq +*/ +struct scif_info { +u8 nodeid; +u8 maxid; +u8 total; +u32 nr_zombies; +spinlock_t eplock; +struct mutex connlock; +spinlock_t nb_connect_lock; +spinlock_t port_lock; +struct list_head uaccept; +struct list_head listen; +struct list_head zombie; +struct list_head connected; +struct list_head disconnected; +struct list_head nb_connect_list; +struct work_struct misc_work; +struct mutex conflock; +u8 en_msg_log; +u8 p2p_enable; +struct miscdevice miscdev; +struct work_struct conn_work; +wait_queue_head_t exitwq; +struct scif_dev *loopb_dev; +struct workqueue_struct *loopb_wq; +char loopb_wqname[16 ]; +struct work_struct loopb_work; +struct list_head loopb_recv_q; +}; + +/* +* struct scif_p2p_info - SCIF mapping information used for P2P +* +* @ppi_peer_id - SCIF peer node id +* @ppi_sg - Scatter list for bar information (One for mmio and one for aper) +* @sg_nentries - Number of entries in the scatterlist +* @ppi_da: DMA address for MMIO and APER bars +* @ppi_len: Length of MMIO and APER bars +* @ppi_list: Link in list of mapping information +*/ +struct scif_p2p_info { +u8 ppi_peer_id; +struct scatterlist *ppi_sg[2 ]; +u64 sg_nentries[2 ]; +dma_addr_t ppi_da[2 ]; +u64 ppi_len[2 ]; +#define SCIF_PPI_MMIO 0 +#define SCIF_PPI_APER 1 +struct list_head ppi_list; +}; + +/* +* struct scif_dev - SCIF remote device specific fields +* +* @node: Node id +* @p2p: List of P2P mapping information +* @qpairs: The node queue pair for exchanging control messages +* @intr_wq: Workqueue for handling Node QP messages +* @intr_wqname: Name of node QP workqueue for handling interrupts +* @intr_bh: Used for submitting work to intr_wq +* @lock: Lock used for synchronizing access to the scif device +* @sdev: SCIF hardware device on the SCIF hardware bus +* @db: doorbell the peer will trigger to generate an interrupt on self +* @rdb: Doorbell to trigger on the peer to generate an interrupt on the peer +* @cookie: Cookie received while registering the interrupt handler +* @qp_dma_addr: Queue pair DMA address passed to the peer +* @p2p_dwork: Delayed work to enable polling for P2P state +* @qp_dwork: Delayed work for enabling polling for remote QP information +* @p2p_retry: Number of times to retry polling of P2P state +* @base_addr: P2P aperture bar base address +* @mic_mw mmio: The peer MMIO information used for P2P +* @spdev: SCIF peer device on the SCIF peer bus +* @node_remove_ack_pending: True if a node_remove_ack is pending +* @exit_ack_pending: true if an exit_ack is pending +* @disconn_wq: Used while waiting for a node remove response +* @disconn_rescnt: Keeps track of number of node remove requests sent +* @exit: Status of exit message +*/ +struct scif_dev { +u8 node; +struct list_head p2p; +struct scif_qp *qpairs; +struct workqueue_struct *intr_wq; +char intr_wqname[16 ]; +struct work_struct intr_bh; +struct mutex lock; +struct scif_hw_dev *sdev; +int db; +int rdb; +struct mic_irq *cookie; +dma_addr_t qp_dma_addr; +struct delayed_work p2p_dwork; +struct delayed_work qp_dwork; +int p2p_retry; +dma_addr_t base_addr; +struct mic_mw mmio; +struct scif_peer_dev __rcu *spdev; +bool node_remove_ack_pending; +bool exit_ack_pending; +wait_queue_head_t disconn_wq; +atomic_t disconn_rescnt; +enum scif_msg_state exit; +}; + +extern struct scif_info scif_info; +extern struct idr scif_ports; +extern struct scif_dev *scif_dev; +extern const struct file_operations scif_fops; + +/* Size of the RB for the Node QP */ +#define SCIF_NODE_QP_SIZE 0x10000 + +#include "scif_nodeqp.h" + +/* +* scifdev_self: +* @dev: The remote SCIF Device +* +* Returns true if the SCIF Device passed is the self aka Loopback SCIF device. +*/ +static inline int scifdev_self (struct scif_dev *dev) +{ +return dev->node == scif_info.nodeid; +} + +static inline bool scif_is_mgmt_node (void ) +{ +return !scif_info.nodeid; +} + +/* +* scifdev_is_p2p: +* @dev: The remote SCIF Device +* +* Returns true if the SCIF Device is a MIC Peer to Peer SCIF device. +*/ +static inline bool scifdev_is_p2p (struct scif_dev *dev) +{ +if (scif_is_mgmt_node ()) +return false; +else +return dev != &scif_dev[SCIF_MGMT_NODE ] && + !scifdev_self (dev); +} + +/* +* scifdev_alive: +* @scifdev: The remote SCIF Device +* +* Returns true if the remote SCIF Device is running or sleeping for +* this endpoint. +*/ +static inline int _scifdev_alive (struct scif_dev *scifdev) +{ +struct scif_peer_dev *spdev; + +rcu_read_lock (); + spdev =rcu_dereference (scifdev->spdev); +rcu_read_unlock (); +return !!spdev; +} + +void __init scif_init_debugfs (void ); +void scif_exit_debugfs (void ); +int scif_setup_intr_wq (struct scif_dev *scifdev); +void scif_destroy_intr_wq (struct scif_dev *scifdev); +void scif_cleanup_scifdev (struct scif_dev *dev); +void scif_handle_remove_node (int node); +void scif_disconnect_node (u32 node_id,bool mgmt_initiated); +void scif_free_qp (struct scif_dev *dev); +void scif_misc_handler (struct work_struct *work); +void scif_stop (struct scif_dev *scifdev); +irqreturn_t scif_intr_handler (int irq,void *data); +#endif /* SCIF_MAIN_H */
drivers/misc/mic/scif/scif_map.h new file +113 -0
113 lines not on this page · raw message
drivers/misc/mic/scif/scif_debugfs.c new file +82 -0
82 lines not on this page · raw message
drivers/misc/mic/scif/scif_main.c new file +394 -0
394 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 1/13 misc: mic: SCIF header file and IOCTL interface
In reply to Sudeep DuttThis patch introduces the SCIF documentation in the header file and describes the IOCTL interface for user mode. mic_overview.txt is updated with documentation on SCIF and a new document describing SCIF in more details is available in scif_overview.txt.
--- Documentation/mic/mic_overview.txt | 28 +- Documentation/mic/scif_overview.txt | 62 ++ include/uapi/linux/Kbuild | 1 + include/linux/scif.h | 1132 +++++++++++++++++++++++++++++++++++ include/uapi/linux/scif_ioctl.h | 233 +++++++ 5 files changed, 1444 insertions(+), 12 deletions(-) create mode 100644 Documentation/mic/scif_overview.txt create mode 100644 include/linux/scif.h create mode 100644 include/uapi/linux/scif_ioctl.h
Documentation/mic/mic_overview.txt +16 -12
@@ -24,6 +24,10 @@ a virtual bus called mic bus is created and virtual dma devices are created on it by the host/card drivers. On host the channels are private and used only by the host driver to transfer data for the virtio devices. +The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a +low level communications API across PCIe currently implemented for MIC. +More details are available at scif_overview.txt. + Here is a block diagram of the various components described above. The virtio backends are situated on the host rather than the card given better single threaded performance for the host compared to MIC, the ability of
@@ -47,18 +51,18 @@ the fact that the virtio block storage backend can only be on the host. | | | Virtio over PCIe IOCTLs | | | +--------------------------+ +-----------+ | | | +-----------+ -| MIC DMA | | | | | MIC DMA | -| Driver | | | | | Driver | -+-----------+ | | | +-----------+ - | | | | | -+---------------+ | | | +----------------+ -|MIC virtual Bus| | | | |MIC virtual Bus | -+---------------+ | | | +----------------+ - | | | | | - | +--------------+ | +---------------+ | - | |Intel MIC | | |Intel MIC | | - +---|Card Driver | | |Host Driver | | - +--------------+ | +---------------+-----+ +| MIC DMA | | +----------+ | +-----------+ | | MIC DMA | +| Driver | | | SCIF | | | SCIF | | | Driver | ++-----------+ | +----------+ | +-----------+ | +-----------+ + | | | | | | | ++---------------+ | +-----+-----+ | +-----+-----+ | +---------------+ +|MIC virtual Bus| | |SCIF HW Bus| | |SCIF HW BUS| | |MIC virtual Bus| ++---------------+ | +-----------+ | +-----+-----+ | +---------------+ + | | | | | | | + | +--------------+ | | | +---------------+ | + | |Intel MIC | | | | |Intel MIC | | + +---|Card Driver +----+ | | |Host Driver | | + +--------------+ | +----+---------------+-----+ | | | +-------------------------------------------------------------+ | |
Documentation/mic/scif_overview.txt new file +62 -0
62 lines not on this page · raw message
include/uapi/linux/Kbuild +1 -0
@@ -345,6 +345,7 @@ header-y += rtc.h header-y += rtnetlink.h header-y += scc.h header-y += sched.h +header-y += scif_ioctl.h header-y += screen_info.h header-y += sctp.h header-y += sdla.h
include/linux/scif.h new file +1132 -0
1,132 lines not on this page · raw message
include/uapi/linux/scif_ioctl.h new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 11/13 misc: mic: MIC host driver specific changes to enable SCIF
In reply to Sudeep DuttMIC host driver specific changes to enable SCIF. This patch implements the SCIF hardware bus operations and registers a SCIF device on the SCIF hardware bus.
--- drivers/misc/mic/Kconfig | 2 +- drivers/misc/mic/host/mic_device.h | 11 +- drivers/misc/mic/host/mic_intr.h | 3 +- drivers/misc/mic/host/mic_smpt.h | 1 + drivers/misc/mic/host/mic_boot.c | 264 ++++++++++++++++++++++++++++++++++-- drivers/misc/mic/host/mic_debugfs.c | 13 ++ drivers/misc/mic/host/mic_main.c | 6 + drivers/misc/mic/host/mic_smpt.c | 7 +- drivers/misc/mic/host/mic_virtio.c | 6 +- drivers/misc/mic/host/mic_x100.c | 3 +- 10 files changed, 292 insertions(+), 24 deletions(-)
drivers/misc/mic/Kconfig +1 -1
@@ -36,7 +36,7 @@ comment "Intel MIC Host Driver" config INTEL_MIC_HOST tristate "Intel MIC Host Driver" - depends on 64BIT && PCI && X86 && INTEL_MIC_BUS + depends on 64BIT && PCI && X86 && INTEL_MIC_BUS && SCIF_BUS select VHOST_RING help This enables Host Driver support for the Intel Many Integrated
drivers/misc/mic/host/mic_device.h +8 -3
@@ -27,7 +27,7 @@#include <linux/irqreturn.h> #include <linux/dmaengine.h> #include <linux/mic_bus.h> - +#include "../bus/scif_bus.h" #include "mic_intr.h" /* The maximum number of MIC devices supported in a single host system. */
@@ -90,7 +90,9 @@ enum mic_stepping {* @vdev_list: list of virtio devices. * @pm_notifier: Handles PM notifications from the OS. * @dma_mbdev: MIC BUS DMA device. -* @dma_ch: DMA channel reserved by this driver for use by virtio devices. +* @dma_ch - Array of DMA channels +* @num_dma_ch - Number of DMA channels available +* @scdev: SCIF device on the SCIF virtual bus. */ struct mic_device {struct mic_mw mmio;
@@ -129,7 +131,9 @@ struct mic_device {struct list_head vdev_list;struct notifier_block pm_notifier;struct mbus_device *dma_mbdev; -struct dma_chan *dma_ch; +struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN ]; +int num_dma_ch; +struct scif_hw_dev *scdev; };/**
@@ -228,4 +232,5 @@ void mic_exit_debugfs(void);void mic_prepare_suspend (struct mic_device *mdev);void mic_complete_resume (struct mic_device *mdev);void mic_suspend (struct mic_device *mdev); +extern atomic_t g_num_mics;#endif
drivers/misc/mic/host/mic_intr.h +2 -1
@@ -28,8 +28,9 @@* 3 for virtio network, console and block devices. * 1 for card shutdown notifications. * 4 for host owned DMA channels. +* 1 for SCIF */ -#define MIC_MIN_MSIX 8 +#define MIC_MIN_MSIX 9#define MIC_NUM_OFFSETS 32/**
drivers/misc/mic/host/mic_smpt.h +1 -0
@@ -78,6 +78,7 @@ void mic_unmap_single(struct mic_device *mdev,dma_addr_t mic_map (struct mic_device *mdev,dma_addr_t dma_addr,size_t size);void mic_unmap (struct mic_device *mdev,dma_addr_t mic_addr,size_t size); +dma_addr_t mic_to_dma_addr (struct mic_device *mdev,dma_addr_t mic_addr);/** * mic_map_error - Check a MIC address for errors.
drivers/misc/mic/host/mic_boot.c +254 -10
311 lines not on this page · raw message
drivers/misc/mic/host/mic_debugfs.c +13 -0
@@ -214,6 +214,19 @@ static int mic_dp_show(struct seq_file *s, void *pos) bootparam->shutdown_status);seq_printf (s,"Bootparam: shutdown_card %d\n" , bootparam->shutdown_card); +seq_printf (s,"Bootparam: tot_nodes %d\n" , + bootparam->tot_nodes); +seq_printf (s,"Bootparam: node_id %d\n" , + bootparam->node_id); +seq_printf (s,"Bootparam: c2h_scif_db %d\n" , + bootparam->c2h_scif_db); +seq_printf (s,"Bootparam: h2c_scif_db %d\n" , + bootparam->h2c_scif_db); +seq_printf (s,"Bootparam: scif_host_dma_addr 0x%llx\n" , + bootparam->scif_host_dma_addr); +seq_printf (s,"Bootparam: scif_card_dma_addr 0x%llx\n" , + bootparam->scif_card_dma_addr); +for (i =sizeof (*bootparam); i <MIC_DP_SIZE ; i +=mic_total_desc_size (d)) {
drivers/misc/mic/host/mic_main.c +6 -0
@@ -67,6 +67,8 @@ static struct ida g_mic_ida;static struct class *g_mic_class;/* Base device node number for MIC devices */ static dev_t g_mic_devno; +/* Track the total number of MIC devices */ +atomic_t g_num_mics;static const struct file_operations mic_fops = { .open = mic_open,
@@ -408,6 +410,7 @@ static int mic_probe(struct pci_dev *pdev,dev_err (&pdev->dev,"cdev_add err id %d rc %d\n" , mdev->id, rc); goto cleanup_debug_dir; } +atomic_inc (&g_num_mics);return 0 ; cleanup_debug_dir:mic_delete_debug_dir (mdev);
@@ -459,6 +462,7 @@ static void mic_remove(struct pci_dev *pdev)return ;mic_stop (mdev, false); +atomic_dec (&g_num_mics);cdev_del (&mdev->cdev);mic_delete_debug_dir (mdev);mutex_lock (&mdev->mic_mutex);
@@ -478,6 +482,7 @@ static void mic_remove(struct pci_dev *pdev)ida_simple_remove (&g_mic_ida, mdev->id);kfree (mdev); } +static struct pci_driver mic_driver = { .name = mic_driver_name, .id_table = mic_pci_tbl,
@@ -512,6 +517,7 @@ static int __init mic_init(void) }return ret; cleanup_debugfs: +ida_destroy (&g_mic_ida);mic_exit_debugfs ();class_destroy (g_mic_class); cleanup_chrdev:
drivers/misc/mic/host/mic_smpt.c +3 -4
@@ -174,8 +174,7 @@ static int mic_get_smpt_ref_count(struct mic_device *mdev, dma_addr_t dma_addr,* * returns a DMA address. */ -static dma_addr_t -mic_to_dma_addr (struct mic_device *mdev,dma_addr_t mic_addr) +dma_addr_t mic_to_dma_addr (struct mic_device *mdev,dma_addr_t mic_addr) {struct mic_smpt_info *smpt_info = mdev->smpt;int spt;
@@ -214,7 +213,7 @@ dma_addr_t mic_map(struct mic_device *mdev, dma_addr_t dma_addr, size_t size)if (!size || size >mic_max_system_memory (mdev))return mic_addr; - ref =kmalloc (mdev->smpt->info.num_reg *sizeof (s64),GFP_KERNEL ); + ref =kmalloc_array (mdev->smpt->info.num_reg,sizeof (s64),GFP_ATOMIC );if (!ref)return mic_addr;
@@ -271,7 +270,7 @@ void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size) } spt =mic_sys_addr_to_smpt (mdev, mic_addr); - ref =kmalloc (mdev->smpt->info.num_reg *sizeof (s64),GFP_KERNEL ); + ref =kmalloc_array (mdev->smpt->info.num_reg,sizeof (s64),GFP_ATOMIC );if (!ref)return ;
drivers/misc/mic/host/mic_virtio.c +3 -3
@@ -40,7 +40,7 @@ static int mic_sync_dma(struct mic_device *mdev, dma_addr_t dst, {int err =0 ;struct dma_async_tx_descriptor *tx; -struct dma_chan *mic_ch = mdev->dma_ch; +struct dma_chan *mic_ch = mdev->dma_ch[0 ];if (!mic_ch) { err = -EBUSY ;
@@ -80,7 +80,7 @@ static int mic_virtio_copy_to_user(struct mic_vdev *mvdev, void __user *ubuf,struct mic_device *mdev = mvdev->mdev;void __iomem *dbuf = mdev->aper.va + daddr;struct mic_vringh *mvr = &mvdev->mvr[vr_idx]; -size_t dma_alignment =1 << mdev->dma_ch->device->copy_align; +size_t dma_alignment =1 << mdev->dma_ch[0 ]->device->copy_align;size_t dma_offset;size_t partlen;int err;
@@ -129,7 +129,7 @@ static int mic_virtio_copy_from_user(struct mic_vdev *mvdev, void __user *ubuf,struct mic_device *mdev = mvdev->mdev;void __iomem *dbuf = mdev->aper.va + daddr;struct mic_vringh *mvr = &mvdev->mvr[vr_idx]; -size_t dma_alignment =1 << mdev->dma_ch->device->copy_align; +size_t dma_alignment =1 << mdev->dma_ch[0 ]->device->copy_align;size_t partlen;int err;
drivers/misc/mic/host/mic_x100.c +1 -2
@@ -167,8 +167,7 @@ static void mic_x100_send_intr(struct mic_device *mdev, int doorbell)if (doorbell <MIC_X100_NUM_SBOX_IRQ ) {mic_x100_send_sbox_intr (mdev, doorbell); }else { - rdmasr_db = doorbell -MIC_X100_NUM_SBOX_IRQ + -MIC_X100_RDMASR_IRQ_BASE ; + rdmasr_db = doorbell -MIC_X100_NUM_SBOX_IRQ ;mic_x100_send_rdmasr_intr (mdev, rdmasr_db); } }
Signature · 1 line
1.8.2.1
Greg Kroah-Hartman
maintainerRe: [PATCH char-misc-next 01/13] misc: mic: SCIF header file and IOCTL interface
In reply to Sudeep DuttQuoted 254 lines · Sudeep Dutt
This patch introduces the SCIF documentation in the header file and describes the IOCTL interface for user mode. mic_overview.txt is updated with documentation on SCIF and a new document describing SCIF in more details is available in scif_overview.txt.
Reviewed-by Nikhil Rao <[email protected]>Reviewed-by Ashutosh Dixit <[email protected]>Signed-off-by Sudeep Dutt <[email protected]>--- Documentation/mic/mic_overview.txt | 28 +- Documentation/mic/scif_overview.txt | 62 ++ include/uapi/linux/Kbuild | 1 + include/linux/scif.h | 1132 +++++++++++++++++++++++++++++++++++ include/uapi/linux/scif_ioctl.h | 233 +++++++ 5 files changed, 1444 insertions(+), 12 deletions(-) create mode 100644 Documentation/mic/scif_overview.txt create mode 100644 include/linux/scif.h create mode 100644 include/uapi/linux/scif_ioctl.hDocumentation/mic/mic_overview.txt +16
-12@@ -24,6 +24,10 @@ a virtual bus called mic bus is created and virtual dma devices are created on it by the host/card drivers. On host the channels are private and used only by the host driver to transfer data for the virtio devices. +The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a +low level communications API across PCIe currently implemented for MIC. +More details are available at scif_overview.txt. + Here is a block diagram of the various components described above. The virtio backends are situated on the host rather than the card given better single threaded performance for the host compared to MIC, the ability of@@ -47,18 +51,18 @@ the fact that the virtio block storage backend can only be on the host. | | | Virtio over PCIe IOCTLs | | | +--------------------------+ +-----------+ | | | +-----------+ -| MIC DMA | | | | | MIC DMA | -| Driver | | | | | Driver | -+-----------+ | | | +-----------+ - | | | | | -+---------------+ | | | +----------------+ -|MIC virtual Bus| | | | |MIC virtual Bus | -+---------------+ | | | +----------------+ - | | | | | - | +--------------+ | +---------------+ | - | |Intel MIC | | |Intel MIC | | - +---|Card Driver | | |Host Driver | | - +--------------+ | +---------------+-----+ +| MIC DMA | | +----------+ | +-----------+ | | MIC DMA | +| Driver | | | SCIF | | | SCIF | | | Driver | ++-----------+ | +----------+ | +-----------+ | +-----------+ + | | | | | | | ++---------------+ | +-----+-----+ | +-----+-----+ | +---------------+ +|MIC virtual Bus| | |SCIF HW Bus| | |SCIF HW BUS| | |MIC virtual Bus| ++---------------+ | +-----------+ | +-----+-----+ | +---------------+ + | | | | | | | + | +--------------+ | | | +---------------+ | + | |Intel MIC | | | | |Intel MIC | | + +---|Card Driver +----+ | | |Host Driver | | + +--------------+ | +----+---------------+-----+ | | | +-------------------------------------------------------------+ | |Documentation/mic/scif_overview.txt new file +62
-0@@ -0,0 +1,62 @@ +The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a low +level communications API across PCIe currently implemented for MIC. Currently +SCIF provides inter-node communication within a single host platform, where a +node is a MIC Coprocessor or Xeon based host. SCIF abstracts the details of +communicating over the PCIe bus while providing an API that is symmetric +across all the nodes in the PCIe network. An important design objective for SCIF +is to deliver the maximum possible performance given the communication +abilities of the hardware. SCIF has been used to implement an offload compiler +runtime and OFED support for MPI implementations for MIC coprocessors. + +==== SCIF API Components ==== +The SCIF API has the following parts: +1. Connection establishment using a client server model +2. Byte stream messaging intended for short messages +3. Node enumeration to determine online nodes +4. Poll semantics for detection of incoming connections and messages +5. Memory registration to pin down pages +6. Remote memory mapping for low latency CPU accesses via mmap +7. Remote DMA (RDMA) for high bandwidth DMA transfers +8. Fence APIs for RDMA synchronization + +SCIF exposes the notion of a connection which can be used by peer processes on +nodes in a SCIF PCIe "network" to share memory "windows" and to communicate. A +process in a SCIF node initiates a SCIF connection to a peer process on a +different node via a SCIF "endpoint". SCIF endpoints support messaging APIs +which are similar to connection oriented socket APIs. Connected SCIF endpoints +can also register local memory which is followed by data transfer using either +DMA, CPU copies or remote memory mapping via mmap. SCIF supports both user and +kernel mode clients which are functionally equivalent. + +==== SCIF Performance for MIC ==== +DMA bandwidth comparison between the TCP (over ethernet over PCIe) stack versus +SCIF shows the performance advantages of SCIF for HPC applications and runtimes. + + Comparison of TCP and SCIF based BW + + Throughput (GB/sec) + 8 + PCIe Bandwidth ****** + + TCP ###### + 7 + ************************************** SCIF %%%%%% + | %%%%%%%%%%%%%%%%%%% + 6 + %%%% + | %% + | %%% + 5 + %% + | %% + 4 + %% + | %% + 3 + %% + | % + 2 + %% + | %% + | % + 1 + + + ###################################### + 0 +++---+++--+--+-+--+--+-++-+--+-++-+--+-++-+- + 1 10 100 1000 10000 100000 + Transfer Size (KBytes) + +SCIF allows memory sharing via mmap(..) between processes on different PCIe +nodes and thus provides bare-metal PCIe latency. The round trip SCIF mmap +latency from the host to an x100 MIC for an 8 byte message is 0.44 usecs.include/uapi/linux/Kbuild +1
-0@@ -345,6 +345,7 @@ header-y += rtc.h header-y += rtnetlink.h header-y += scc.h header-y += sched.h +header-y += scif_ioctl.h header-y += screen_info.h header-y += sctp.h header-y += sdla.hinclude/linux/scif.h new file +103
-0@@ -0,0 +1,1132 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* BSD LICENSE +* +* Copyright(c) 2014 Intel Corporation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Intel SCIF driver. +* +*/ +#ifndef __SCIF_H__ +#define __SCIF_H__ + +#include <linux/types.h> +#include <linux/poll.h> +#include <linux/scif_ioctl.h> + +#define SCIF_ACCEPT_SYNC 1 +#define SCIF_SEND_BLOCK 1 +#define SCIF_RECV_BLOCK 1 + +enum { +SCIF_PROT_READ = (1 <<0 ), +SCIF_PROT_WRITE = (1 <<1 ) +}; + +enum { +SCIF_MAP_FIXED =0x10 , +SCIF_MAP_KERNEL =0x20 , +}; + +enum { +SCIF_FENCE_INIT_SELF = (1 <<0 ), +SCIF_FENCE_INIT_PEER = (1 <<1 ), +SCIF_SIGNAL_LOCAL = (1 <<4 ), +SCIF_SIGNAL_REMOTE = (1 <<5 ) +}; + +enum { +SCIF_RMA_USECPU = (1 <<0 ), +SCIF_RMA_USECACHE = (1 <<1 ), +SCIF_RMA_SYNC = (1 <<2 ), +SCIF_RMA_ORDERED = (1 <<3 ) +}; + +/* End of SCIF Admin Reserved Ports */ +#define SCIF_ADMIN_PORT_END 1024 + +/* End of SCIF Reserved Ports */ +#define SCIF_PORT_RSVD 1088 + +typedef struct scif_endpt *scif_epd_t ; + +#define SCIF_OPEN_FAILED ((scif_epd_t)-1) +#define SCIF_REGISTER_FAILED ((off_t)-1) +#define SCIF_MMAP_FAILED ((void *)-1) + +/** +* scif_open - Create an endpoint +* +*\return
include/linux/scif.h line 113
Quoted 10 lines
include/linux/scif.h new file +10
-0+* Upon successful completion, scif_open() returns an endpoint descriptor to +* be used in subsequent SCIF functions calls to refer to that endpoint; +* otherwise: in user mode SCIF_OPEN_FAILED (that is ((scif_epd_t)-1)) is +* returned and errno is set to indicate the error; in kernel mode a NULL +* scif_epd_t is returned. +* +*\par Errors: +*- ENOMEM +* - Insufficient kernel memory was available +*/
Documentation is great, but if you are going to do it, use the proper kerneldoc format and not some other odd variant that I have never seen before. This whole patch has tons of oddly labled comments, like this:
include/linux/scif.h line 119
Quoted 4 lines
include/linux/scif.h new file +4
-0+/** +* scif _bind - Bind an endpoint to a port +* \param epd endpoint descriptor +* \param pn port number
Please fix up, I can't take any of this, sorry.
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH char-misc-next 02/13] misc: mic: SCIF ring buffer infrastructure
In reply to Sudeep DuttQuoted 7 lines · Sudeep Dutt
SCIF ring buffer is a single producer, single consumer byte stream ring buffer optimized for avoiding reads across the PCIe bus. The ring buffer is used to implement a receive queue for SCIF driver messaging between nodes and for byte stream messaging between SCIF endpoints. Each SCIF node has a receive queue for every other SCIF node, and each connected endpoint has a receive queue for messages from its peer. This pair of receive queues is referred to as a SCIF queue pair.
And the reason you aren't using the built-in kernel ring buffer code is why?
You need to document that really well here, or use the in-kernel code please.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH char-misc-next 04/13] misc: mic: SCIF Peer Bus
In reply to Sudeep DuttQuoted 71 lines · Sudeep Dutt
The SCIF peer bus is used to register and unregister SCIF peer devices internally by the SCIF driver to signify the addition and removal of peer nodes respectively from the SCIF network. This simplifies remote node handling within SCIF and will also be used to support device probe/remove for SCIF client drivers (e.g. netdev over SCIF)
Reviewed-by Nikhil Rao <[email protected]>Reviewed-by Ashutosh Dixit <[email protected]>Signed-off-by Sudeep Dutt <[email protected]>--- drivers/misc/mic/scif/scif_peer_bus.h | 63 +++++++++++++++++ drivers/misc/mic/scif/scif_peer_bus.c | 124 ++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_peer_bus.h create mode 100644 drivers/misc/mic/scif/scif_peer_bus.cdrivers/misc/mic/scif/scif_peer_bus.h new file +49
-0@@ -0,0 +1,63 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* Intel SCIF driver. +*/ +#ifndef _SCIF_PEER_BUS_H_ +#define _SCIF_PEER_BUS_H_ + +#include <linux/device.h> +#include <linux/mic_common.h> + +/* + * Peer devices show up as PCIe devices for the mgmt node but not the cards. + * The mgmt node discovers all the cards on the PCIe bus and informs the other + * cards about their peers. Upon notification of a peer a node adds a peer + * device to the peer bus to maintain symmetry in the way devices are + * discovered across all nodes in the SCIF network. + */ +/** + * scif_peer_dev - representation of a peer SCIF device + * @dev: underlying device + * @dnode - The destination node which this device will communicate with. + */ +struct scif_peer_dev { + struct device dev; + u8 dnode; +}; + +/** + * scif_peer_driver - operations for a scif_peer I/O driver + * @driver: underlying device driver (populate name and owner). + * @id_table: the ids serviced by this driver. + * @probe: the function to call when a device is found. Returns 0 or -errno. + * @remove: the function to call when a device is removed. + */ +struct scif_peer_driver { + struct device_driver driver; + const struct scif_peer_dev_id *id_table;
drivers/misc/mic/scif/scif_peer_bus.h line 59
Quoted 10 lines
drivers/misc/mic/scif/scif_peer_bus.h new file +10
-0+ +int (*probe)(struct scif_peer_dev *dev); +void (*remove)(struct scif_peer_dev *dev); +}; + +int scif_peer_register_driver (struct scif_peer_driver *driver); +void scif_peer_unregister_driver (struct scif_peer_driver *driver); +struct scif_dev ; +struct scif_peer_dev * +scif_peer_register_device (struct scif_dev *sdev);
Odd formatting, don't you think?
Please put your "predeclare scif_dev" on an earlier line by itself, as this is a mess.
thanks,
greg k-h
Re: [PATCH char-misc-next 01/13] misc: mic: SCIF header file and IOCTL interface
In reply to Greg Kroah-HartmanQuoted 261 lines · Greg Kroah-Hartman
Quoted 260 lines · Sudeep Dutt
This patch introduces the SCIF documentation in the header file and describes the IOCTL interface for user mode. mic_overview.txt is updated with documentation on SCIF and a new document describing SCIF in more details is available in scif_overview.txt.
Reviewed-by Nikhil Rao <[email protected]>Reviewed-by Ashutosh Dixit <[email protected]>Signed-off-by Sudeep Dutt <[email protected]>--- Documentation/mic/mic_overview.txt | 28 +- Documentation/mic/scif_overview.txt | 62 ++ include/uapi/linux/Kbuild | 1 + include/linux/scif.h | 1132 +++++++++++++++++++++++++++++++++++ include/uapi/linux/scif_ioctl.h | 233 +++++++ 5 files changed, 1444 insertions(+), 12 deletions(-) create mode 100644 Documentation/mic/scif_overview.txt create mode 100644 include/linux/scif.h create mode 100644 include/uapi/linux/scif_ioctl.hDocumentation/mic/mic_overview.txt +16
-12@@ -24,6 +24,10 @@ a virtual bus called mic bus is created and virtual dma devices are created on it by the host/card drivers. On host the channels are private and used only by the host driver to transfer data for the virtio devices. +The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a +low level communications API across PCIe currently implemented for MIC. +More details are available at scif_overview.txt. + Here is a block diagram of the various components described above. The virtio backends are situated on the host rather than the card given better single threaded performance for the host compared to MIC, the ability of@@ -47,18 +51,18 @@ the fact that the virtio block storage backend can only be on the host. | | | Virtio over PCIe IOCTLs | | | +--------------------------+ +-----------+ | | | +-----------+ -| MIC DMA | | | | | MIC DMA | -| Driver | | | | | Driver | -+-----------+ | | | +-----------+ - | | | | | -+---------------+ | | | +----------------+ -|MIC virtual Bus| | | | |MIC virtual Bus | -+---------------+ | | | +----------------+ - | | | | | - | +--------------+ | +---------------+ | - | |Intel MIC | | |Intel MIC | | - +---|Card Driver | | |Host Driver | | - +--------------+ | +---------------+-----+ +| MIC DMA | | +----------+ | +-----------+ | | MIC DMA | +| Driver | | | SCIF | | | SCIF | | | Driver | ++-----------+ | +----------+ | +-----------+ | +-----------+ + | | | | | | | ++---------------+ | +-----+-----+ | +-----+-----+ | +---------------+ +|MIC virtual Bus| | |SCIF HW Bus| | |SCIF HW BUS| | |MIC virtual Bus| ++---------------+ | +-----------+ | +-----+-----+ | +---------------+ + | | | | | | | + | +--------------+ | | | +---------------+ | + | |Intel MIC | | | | |Intel MIC | | + +---|Card Driver +----+ | | |Host Driver | | + +--------------+ | +----+---------------+-----+ | | | +-------------------------------------------------------------+ | |Documentation/mic/scif_overview.txt new file +62
-0@@ -0,0 +1,62 @@ +The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a low +level communications API across PCIe currently implemented for MIC. Currently +SCIF provides inter-node communication within a single host platform, where a +node is a MIC Coprocessor or Xeon based host. SCIF abstracts the details of +communicating over the PCIe bus while providing an API that is symmetric +across all the nodes in the PCIe network. An important design objective for SCIF +is to deliver the maximum possible performance given the communication +abilities of the hardware. SCIF has been used to implement an offload compiler +runtime and OFED support for MPI implementations for MIC coprocessors. + +==== SCIF API Components ==== +The SCIF API has the following parts: +1. Connection establishment using a client server model +2. Byte stream messaging intended for short messages +3. Node enumeration to determine online nodes +4. Poll semantics for detection of incoming connections and messages +5. Memory registration to pin down pages +6. Remote memory mapping for low latency CPU accesses via mmap +7. Remote DMA (RDMA) for high bandwidth DMA transfers +8. Fence APIs for RDMA synchronization + +SCIF exposes the notion of a connection which can be used by peer processes on +nodes in a SCIF PCIe "network" to share memory "windows" and to communicate. A +process in a SCIF node initiates a SCIF connection to a peer process on a +different node via a SCIF "endpoint". SCIF endpoints support messaging APIs +which are similar to connection oriented socket APIs. Connected SCIF endpoints +can also register local memory which is followed by data transfer using either +DMA, CPU copies or remote memory mapping via mmap. SCIF supports both user and +kernel mode clients which are functionally equivalent. + +==== SCIF Performance for MIC ==== +DMA bandwidth comparison between the TCP (over ethernet over PCIe) stack versus +SCIF shows the performance advantages of SCIF for HPC applications and runtimes. + + Comparison of TCP and SCIF based BW + + Throughput (GB/sec) + 8 + PCIe Bandwidth ****** + + TCP ###### + 7 + ************************************** SCIF %%%%%% + | %%%%%%%%%%%%%%%%%%% + 6 + %%%% + | %% + | %%% + 5 + %% + | %% + 4 + %% + | %% + 3 + %% + | % + 2 + %% + | %% + | % + 1 + + + ###################################### + 0 +++---+++--+--+-+--+--+-++-+--+-++-+--+-++-+- + 1 10 100 1000 10000 100000 + Transfer Size (KBytes) + +SCIF allows memory sharing via mmap(..) between processes on different PCIe +nodes and thus provides bare-metal PCIe latency. The round trip SCIF mmap +latency from the host to an x100 MIC for an 8 byte message is 0.44 usecs.include/uapi/linux/Kbuild +1
-0@@ -345,6 +345,7 @@ header-y += rtc.h header-y += rtnetlink.h header-y += scc.h header-y += sched.h +header-y += scif_ioctl.h header-y += screen_info.h header-y += sctp.h header-y += sdla.hinclude/linux/scif.h new file +109
-0@@ -0,0 +1,1132 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* This file is provided under a dual BSD/GPLv2 license. When using or +* redistributing this file, you may do so under either license. +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* BSD LICENSE +* +* Copyright(c) 2014 Intel Corporation. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Intel SCIF driver. +* +*/ +#ifndef __SCIF_H__ +#define __SCIF_H__ + +#include <linux/types.h> +#include <linux/poll.h> +#include <linux/scif_ioctl.h> + +#define SCIF_ACCEPT_SYNC 1 +#define SCIF_SEND_BLOCK 1 +#define SCIF_RECV_BLOCK 1 + +enum { +SCIF_PROT_READ = (1 <<0 ), +SCIF_PROT_WRITE = (1 <<1 ) +}; + +enum { +SCIF_MAP_FIXED =0x10 , +SCIF_MAP_KERNEL =0x20 , +}; + +enum { +SCIF_FENCE_INIT_SELF = (1 <<0 ), +SCIF_FENCE_INIT_PEER = (1 <<1 ), +SCIF_SIGNAL_LOCAL = (1 <<4 ), +SCIF_SIGNAL_REMOTE = (1 <<5 ) +}; + +enum { +SCIF_RMA_USECPU = (1 <<0 ), +SCIF_RMA_USECACHE = (1 <<1 ), +SCIF_RMA_SYNC = (1 <<2 ), +SCIF_RMA_ORDERED = (1 <<3 ) +}; + +/* End of SCIF Admin Reserved Ports */ +#define SCIF_ADMIN_PORT_END 1024 + +/* End of SCIF Reserved Ports */ +#define SCIF_PORT_RSVD 1088 + +typedef struct scif_endpt *scif_epd_t ; + +#define SCIF_OPEN_FAILED ((scif_epd_t)-1) +#define SCIF_REGISTER_FAILED ((off_t)-1) +#define SCIF_MMAP_FAILED ((void *)-1) + +/** +* scif_open - Create an endpoint +* +*\return +* Upon successful completion, scif_open() returns an endpoint descriptor to +* be used in subsequent SCIF functions calls to refer to that endpoint; +* otherwise: in user mode SCIF_OPEN_FAILED (that is ((scif_epd_t)-1)) is +* returned and errno is set to indicate the error; in kernel mode a NULL +* scif_epd_t is returned. +*
Quoted 9 lines
include/linux/scif.h line 113
Quoted 4 lines
include/linux/scif.h new file +4
-0+*\par Errors: +*- ENOMEM +* - Insufficient kernel memory was available +*/ Documentation is great, but if you are going to do it, use the proper kerneldoc format and not some other odd variant that I have never seen before. This whole patch has tons of oddly labled comments, like this:
This file was set up for being an input into doxygen some time back. I agree that it looks really odd so will fix it up and send across a v2 early next week.
Thanks,
Sudeep Dutt
Re: [PATCH char-misc-next 04/13] misc: mic: SCIF Peer Bus
In reply to Greg Kroah-HartmanQuoted 85 lines · Greg Kroah-Hartman
Quoted 71 lines · Sudeep Dutt
The SCIF peer bus is used to register and unregister SCIF peer devices internally by the SCIF driver to signify the addition and removal of peer nodes respectively from the SCIF network. This simplifies remote node handling within SCIF and will also be used to support device probe/remove for SCIF client drivers (e.g. netdev over SCIF)
Reviewed-by Nikhil Rao <[email protected]>Reviewed-by Ashutosh Dixit <[email protected]>Signed-off-by Sudeep Dutt <[email protected]>--- drivers/misc/mic/scif/scif_peer_bus.h | 63 +++++++++++++++++ drivers/misc/mic/scif/scif_peer_bus.c | 124 ++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 drivers/misc/mic/scif/scif_peer_bus.h create mode 100644 drivers/misc/mic/scif/scif_peer_bus.cdrivers/misc/mic/scif/scif_peer_bus.h new file +49
-0@@ -0,0 +1,63 @@ +/* +* Intel MIC Platform Software Stack (MPSS) +* +* Copyright(c) 2014 Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License, version 2, as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* Intel SCIF driver. +*/ +#ifndef _SCIF_PEER_BUS_H_ +#define _SCIF_PEER_BUS_H_ + +#include <linux/device.h> +#include <linux/mic_common.h> + +/* + * Peer devices show up as PCIe devices for the mgmt node but not the cards. + * The mgmt node discovers all the cards on the PCIe bus and informs the other + * cards about their peers. Upon notification of a peer a node adds a peer + * device to the peer bus to maintain symmetry in the way devices are + * discovered across all nodes in the SCIF network. + */ +/** + * scif_peer_dev - representation of a peer SCIF device + * @dev: underlying device + * @dnode - The destination node which this device will communicate with. + */ +struct scif_peer_dev { + struct device dev; + u8 dnode; +}; + +/** + * scif_peer_driver - operations for a scif_peer I/O driver + * @driver: underlying device driver (populate name and owner). + * @id_table: the ids serviced by this driver. + * @probe: the function to call when a device is found. Returns 0 or -errno. + * @remove: the function to call when a device is removed. + */ +struct scif_peer_driver { + struct device_driver driver; + const struct scif_peer_dev_id *id_table;drivers/misc/mic/scif/scif_peer_bus.h line 59
Quoted 10 lines
drivers/misc/mic/scif/scif_peer_bus.h new file +10
-0+ +int (*probe)(struct scif_peer_dev *dev); +void (*remove)(struct scif_peer_dev *dev); +}; + +int scif_peer_register_driver (struct scif_peer_driver *driver); +void scif_peer_unregister_driver (struct scif_peer_driver *driver); +struct scif_dev ; +struct scif_peer_dev * +scif_peer_register_device (struct scif_dev *sdev);Odd formatting, don't you think?
Quoted 2 lines
Please put your "predeclare
scif_dev" on an earlier line by itself, as this is a mess.
I will fix it up and send across a v2 early next week.
Thanks,
Sudeep Dutt
Re: [PATCH char-misc-next 02/13] misc: mic: SCIF ring buffer infrastructure
In reply to Greg Kroah-HartmanQuoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Sudeep Dutt
SCIF ring buffer is a single producer, single consumer byte stream ring buffer optimized for avoiding reads across the PCIe bus. The ring buffer is used to implement a receive queue for SCIF driver messaging between nodes and for byte stream messaging between SCIF endpoints. Each SCIF node has a receive queue for every other SCIF node, and each connected endpoint has a receive queue for messages from its peer. This pair of receive queues is referred to as a SCIF queue pair.
Quoted 3 lines
And the reason you aren't using the built-in kernel ring buffer code is why?
This simple byte stream ring buffer is in our performance data path for small messages and is optimized to avoid reads across the PCIe bus while adding the required barriers and hardware workarounds for the MIC Coprocessor. I will add some more documentation here in the v2 which I will post early next week.
We did not find other ring buffers in the kernel which were tailored for our use case across PCIe. I am guessing (please correct me) that you are referring to the ring buffer in include/linux/ring_buffer.h. It does not seem to be designed for being used between two independent OS's across the PCIe bus. Please let me know your thoughts.
Thanks,
Sudeep Dutt
Greg Kroah-Hartman
maintainerRe: [PATCH char-misc-next 02/13] misc: mic: SCIF ring buffer infrastructure
Quoted 20 lines · Sudeep Dutt
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Sudeep Dutt
SCIF ring buffer is a single producer, single consumer byte stream ring buffer optimized for avoiding reads across the PCIe bus. The ring buffer is used to implement a receive queue for SCIF driver messaging between nodes and for byte stream messaging between SCIF endpoints. Each SCIF node has a receive queue for every other SCIF node, and each connected endpoint has a receive queue for messages from its peer. This pair of receive queues is referred to as a SCIF queue pair.
Quoted 3 lines
And the reason you aren't using the built-in kernel ring buffer code is why?
This simple byte stream ring buffer is in our performance data path for small messages and is optimized to avoid reads across the PCIe bus while adding the required barriers and hardware workarounds for the MIC Coprocessor. I will add some more documentation here in the v2 which I will post early next week.
Quoted 5 lines
We did not find other ring buffers in the kernel which were tailored for our use case across PCIe. I am guessing (please correct me) that you are referring to the ring buffer in
include/linux/ring_buffer.h. It does not seem to be designed for being used between two independent OS's across the PCIe bus. Please let me know your thoughts.
No, it's designed for an in-kernel ringbuffer, so you need to document exactly this.
thanks,
greg k-h