NTB: Fix and cleanup ntb drivers
Subsystems (4)
PATCH 6/9 NTB: Schedule to receive on QP link up
In reply to Allen HubbeSchedule to receive on QP link up, to make sure that the doorbell is properly cleared for interrupts.
--- drivers/ntb/ntb_transport.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ntb/ntb_transport.c +2 -0
@@ -901,6 +901,8 @@ static void ntb_qp_link_work(struct work_struct *work)if (qp->event_handler) qp->event_handler (qp->cb_data, qp->link_is_up); + +tasklet_schedule (&qp->rxc_db_work); }else if (nt->link_is_up)schedule_delayed_work (&qp->link_work,msecs_to_jiffies (NTB_LINK_DOWN_TIMEOUT ));
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 8/9 NTB: Make the transport list in order of discovery
In reply to Allen HubbeFrom: Dave Jiang <[email protected]>
The list should be added from the bottom and not the top in order to ensure the transport is provided in the same order to clients as ntb devices are discovered.
--- drivers/ntb/ntb_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/ntb_transport.c +1 -1
@@ -296,7 +296,7 @@ static LIST_HEAD(ntb_transport_list);static int ntb_bus_init (struct ntb_transport_ctx *nt) { -list_add (&nt->entry, &ntb_transport_list); +list_add_tail (&nt->entry, &ntb_transport_list);return 0 ; }
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 4/9 NTB: ntb_netdev not covering all receive errors
In reply to Allen HubbeFrom: Dave Jiang <mailto:[email protected]>
ntb_netdev is allowing the link to come up even when -ENOMEM is returned from ntb_transport_rx_enqueue. Fix to cover all possible errors.
--- drivers/net/ntb_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ntb_netdev.c +1 -1
@@ -257,7 +257,7 @@ static int ntb_netdev_open(struct net_device *ndev) rc =ntb_transport_rx_enqueue (dev->qp, skb, skb->data, ndev->mtu +ETH_HLEN ); -if (rc == -EINVAL ) { +if (rc) {dev_kfree_skb (skb); goto err; }
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 5/9 NTB: Fix oops in debugfs when transport is half-up
In reply to Allen HubbeFrom: Dave Jiang <[email protected]>
When the remote side is not up, we do not have all the context for the transport, and that causes NULL ptr access. Have the debugfs reads check to see if transport is up before we make access.
--- drivers/ntb/ntb_transport.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ntb/ntb_transport.c +5 -1
@@ -438,13 +438,17 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,char *buf;ssize_t ret, out_offset, out_count; + qp = filp->private_data; + +if (!qp || !qp->link_is_up) +return 0 ; + out_count =1000 ; buf =kmalloc (out_count,GFP_KERNEL );if (!buf)return -ENOMEM ; - qp = filp->private_data; out_offset =0 ; out_offset +=snprintf (buf + out_offset, out_count - out_offset,"NTB QP stats\n" );
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
cover NTB: Fix and cleanup ntb drivers
This series includes the following changes to fix bugs, add new hardware support, and improve usability and performance of the ntb drivers.
Bug Fixes (issues preexisting the new ntb api):
NTB: Fix ntb_transport out-of-order RX update
NTB: Schedule to receive on QP link up
NTB: ntb_netdev not covering all receive errors
NTB: Fix oops in debugfs when transport is half-up
Bug Fixes (regressions since the new ntb api):
NTB: Fix transport stats for multiple devices
Additions:
NTB: Add PCI Device IDs for Broadwell Xeon
NTB: Add flow control to the ntb_netdev
NTB: Make the transport list in order of discovery
NTB: Clean up QP stats info
Allen Hubbe (2):
NTB: Fix ntb_transport out-of-order RX update
NTB: Schedule to receive on QP link up
Dave Jiang (7):
NTB: Add flow control to the ntb_netdev
NTB: Fix transport stats for multiple devices
NTB: ntb_netdev not covering all receive errors
NTB: Fix oops in debugfs when transport is half-up
NTB: Add PCI Device IDs for Broadwell Xeon
NTB: Make the transport list in order of discovery
NTB: Clean up QP stats info
drivers/net/ntb_netdev.c | 80 ++++++++++++- drivers/ntb/hw/intel/ntb_hw_intel.c | 15 +++ drivers/ntb/hw/intel/ntb_hw_intel.h | 3 + drivers/ntb/ntb_transport.c | 228 +++++++++++++++++++++++------------- include/linux/ntb_transport.h | 1 + 5 files changed, 246 insertions(+), 81 deletions(-)
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 3/9 NTB: Fix transport stats for multiple devices
From: Dave Jiang <[email protected]>
Currently the debugfs does not have files for all NTB transport queue pairs. When there are multiple NTBs present in a system, the QP names of the last transport clobber the names of previously added transport QPs. Only the last added QPs can be observed via debugfs.
Create a directory per NTB transport to associate the QPs with that transport. Name the directory the same as the PCI device.
--- drivers/ntb/ntb_transport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/ntb/ntb_transport.c +9 -2
@@ -211,6 +211,8 @@ struct ntb_transport_ctx {bool link_is_up;struct delayed_work link_work;struct work_struct link_cleanup; + +struct dentry *debugfs_node_dir; };enum {
@@ -951,12 +953,12 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, qp->tx_max_frame =min (transport_mtu, tx_size /2 ); qp->tx_max_entry = tx_size / qp->tx_max_frame; -if (nt_debugfs_dir) { +if (nt->debugfs_node_dir) {char debugfs_name[4 ];snprintf (debugfs_name,4 ,"qp%d" , qp_num); qp->debugfs_dir =debugfs_create_dir (debugfs_name, - nt_debugfs_dir); + nt->debugfs_node_dir); qp->debugfs_stats = debugfs_create_file("stats", S_IRUSR, qp->debugfs_dir, qp,
@@ -1059,6 +1061,11 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) goto err2; } +if (nt_debugfs_dir) { + nt->debugfs_node_dir = +debugfs_create_dir (pci_name (ndev->pdev), nt_debugfs_dir); + } +for (i =0 ; i < qp_count; i++) { rc =ntb_transport_init_queue (nt, i);if (rc)
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 1/9 NTB: Fix ntb_transport out-of-order RX update
In reply to Allen HubbeIt was possible for a synchronous update of the RX index in the error case to get ahead of the asynchronous RX index update in the normal case. Change the RX processing to preserve an RX completion order.
There were two error cases. First, if a buffer is not present to receive data, there would be no queue entry to preserve the RX completion order. Instead of dropping the RX frame, leave the RX frame in the ring. Schedule RX processing when RX entries are enqueued, in case there are RX frames waiting in the ring to be received.
Second, if a buffer is too small to receive data, drop the frame in the ring, mark the RX entry as done, and indicate the error in the RX entry length. Check for a negative length in the receive callback in ntb_netdev, and count occurances as rx_length_errors.
--- drivers/net/ntb_netdev.c | 7 ++ drivers/ntb/ntb_transport.c | 168 ++++++++++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 69 deletions(-)
drivers/net/ntb_netdev.c +7 -0
@@ -102,6 +102,12 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,netdev_dbg (ndev,"%s: %d byte payload received\n" , __func__, len); +if (len <0 ) { + ndev->stats.rx_errors++; + ndev->stats.rx_length_errors++; + goto enqueue_again; + } +skb_put (skb, len); skb->protocol =eth_type_trans (skb, ndev); skb->ip_summed =CHECKSUM_NONE ;
@@ -121,6 +127,7 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,return ; } +enqueue_again: rc =ntb_transport_rx_enqueue (qp, skb, skb->data, ndev->mtu +ETH_HLEN );if (rc) {dev_kfree_skb (skb);
drivers/ntb/ntb_transport.c +99 -69
299 lines not on this page · raw message
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 9/9 NTB: Clean up QP stats info
In reply to Allen HubbeFrom: Dave Jiang <[email protected]>
Make QP stats info more readable for debugging purposes. Also add an entry to indicate whether DMA is being used.
--- drivers/ntb/ntb_transport.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
drivers/ntb/ntb_transport.c +16 -9
@@ -451,7 +451,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, out_offset =0 ; out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"NTB QP stats\n" ); +"\nNTB QP stats:\n\n" ); out_offset +=snprintf (buf + out_offset, out_count - out_offset,"rx_bytes - \t%llu\n" , qp->rx_bytes); out_offset += snprintf(buf + out_offset, out_count - out_offset,
@@ -469,11 +469,11 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, out_offset +=snprintf (buf + out_offset, out_count - out_offset,"rx_err_ver - \t%llu\n" , qp->rx_err_ver); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"rx_buff - \t%p\n" , qp->rx_buff); +"rx_buff - \t0x%p\n" , qp->rx_buff); out_offset +=snprintf (buf + out_offset, out_count - out_offset,"rx_index - \t%u\n" , qp->rx_index); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"rx_max_entry - \t%u\n" , qp->rx_max_entry); +"rx_max_entry - \t%u\n\n" , qp->rx_max_entry); out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_bytes - \t%llu\n" , qp->tx_bytes);
@@ -488,21 +488,28 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_err_no_buf - %llu\n" , qp->tx_err_no_buf); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"tx_mw - \t%p\n" , qp->tx_mw); +"tx_mw - \t0x%p\n" , qp->tx_mw); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"tx_index - \t%u\n" , qp->tx_index); +"tx_index (H) - \t%u\n" , qp->tx_index); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"tx_max_entry - \t%u\n" , qp->tx_max_entry); - out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"qp->remote_rx_info->entry - \t%u\n" , +"RRI (T) - \t%u\n" , qp->remote_rx_info->entry); out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"tx_max_entry - \t%u\n" , qp->tx_max_entry); + out_offset +=snprintf (buf + out_offset, out_count - out_offset,"free tx - \t%u\n" ,ntb_transport_tx_free_entry (qp)); out_offset +=snprintf (buf + out_offset, out_count - out_offset, -"\nQP Link %s\n" , +"\n" ); + out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"Using DMA - \t%s\n" , use_dma ?"Yes" :"No" ); + out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"QP Link - \t%s\n" , qp->link_is_up ?"Up" :"Down" ); + out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"\n" ); +if (out_offset > out_count) out_offset = out_count;
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
PATCH 7/9 NTB: Add PCI Device IDs for Broadwell Xeon
In reply to Allen HubbeFrom: Dave Jiang <[email protected]>
Adding PCI Device IDs for B2B (back to back), RP (root port, primary), and TB (transparent bridge, secondary) devices.
--- drivers/ntb/hw/intel/ntb_hw_intel.c | 15 +++++++++++++++ drivers/ntb/hw/intel/ntb_hw_intel.h | 3 +++ 2 files changed, 18 insertions(+)
drivers/ntb/hw/intel/ntb_hw_intel.c +15 -0
@@ -190,14 +190,17 @@ static inline int pdev_is_xeon(struct pci_dev *pdev)case PCI_DEVICE_ID_INTEL_NTB_SS_SNB :case PCI_DEVICE_ID_INTEL_NTB_SS_IVT :case PCI_DEVICE_ID_INTEL_NTB_SS_HSX : +case PCI_DEVICE_ID_INTEL_NTB_SS_BDX :case PCI_DEVICE_ID_INTEL_NTB_PS_JSF :case PCI_DEVICE_ID_INTEL_NTB_PS_SNB :case PCI_DEVICE_ID_INTEL_NTB_PS_IVT :case PCI_DEVICE_ID_INTEL_NTB_PS_HSX : +case PCI_DEVICE_ID_INTEL_NTB_PS_BDX :case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF :case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB :case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT :case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX : +case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX :return 1 ; }return 0 ;
@@ -1844,6 +1847,9 @@ static int xeon_init_dev(struct intel_ntb_dev *ndev)case PCI_DEVICE_ID_INTEL_NTB_SS_HSX :case PCI_DEVICE_ID_INTEL_NTB_PS_HSX :case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX : +case PCI_DEVICE_ID_INTEL_NTB_SS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_PS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX : ndev->hwerr_flags |=NTB_HWERR_SDOORBELL_LOCKUP ;break ; }
@@ -1858,6 +1864,9 @@ static int xeon_init_dev(struct intel_ntb_dev *ndev)case PCI_DEVICE_ID_INTEL_NTB_SS_HSX :case PCI_DEVICE_ID_INTEL_NTB_PS_HSX :case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX : +case PCI_DEVICE_ID_INTEL_NTB_SS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_PS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX : ndev->hwerr_flags |=NTB_HWERR_SB01BASE_LOCKUP ;break ; }
@@ -1879,6 +1888,9 @@ static int xeon_init_dev(struct intel_ntb_dev *ndev)case PCI_DEVICE_ID_INTEL_NTB_SS_HSX :case PCI_DEVICE_ID_INTEL_NTB_PS_HSX :case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX : +case PCI_DEVICE_ID_INTEL_NTB_SS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_PS_BDX : +case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX : ndev->hwerr_flags |=NTB_HWERR_B2BDOORBELL_BIT14 ;break ; }
@@ -2235,14 +2247,17 @@ static const struct pci_device_id intel_ntb_pci_tbl[] = { {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_SNB)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_IVT)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_HSX)}, + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_B2B_BDX)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_JSF)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_SNB)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_IVT)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_HSX)}, + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_PS_BDX)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_JSF)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_SNB)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_IVT)}, {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_HSX)}, + {PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_NTB_SS_BDX)}, {0} };MODULE_DEVICE_TABLE (pci, intel_ntb_pci_tbl);
drivers/ntb/hw/intel/ntb_hw_intel.h +3 -0
@@ -67,6 +67,9 @@#define PCI_DEVICE_ID_INTEL_NTB_PS_HSX 0x2F0E#define PCI_DEVICE_ID_INTEL_NTB_SS_HSX 0x2F0F#define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD 0x0C4E +#define PCI_DEVICE_ID_INTEL_NTB_B2B_BDX 0x6F0D +#define PCI_DEVICE_ID_INTEL_NTB_PS_BDX 0x6F0E +#define PCI_DEVICE_ID_INTEL_NTB_SS_BDX 0x6F0F/* Intel Xeon hardware */
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6
RE: [PATCH 4/9] NTB: ntb_netdev not covering all receive errors
In reply to Allen HubbePiBGcm9tOiBEYXZlIEppYW5nIDxtYWlsdG86ZGF2ZS5qaWFuZ0BpbnRlbC5jb20+DQoNCkkgd2ls bCBmaXggdG8gcmVtb3ZlICJtYWlsdG86IiBpbiB0aGUgY29tbWl0IGF1dGhvci4NCg==
Quoted 1 line
NTB: Add flow control to the
ntb_netdev
PATCH 2/9 tripped some permission and was rejected by my mail server.
I will ask Dave to email this patch separately.
Allen
PATCH 2/9 NTB: Add flow control to the ntb_netdev
In reply to Allen HubbeFrom: Dave Jiang <[email protected]>
Right now if we push the NTB really hard, we start dropping packets due to not able to process the packets fast enough. We need to stop the upper layer from flooding us when that happens.
A timer is necessary in order to restart the queue once the resource has been processed on the receive side. Due to the way NTB is setup, the resources on the tx side are tied to the processing of the rx side and there's no async way to know when the rx side has released those resources.
The following module parameters are added:tx_time: The time in usecs for us to wait before we check if we restart
transmit queue. (default: 1)tx_start: The number of descriptors we wait for to free up before resuming
transmit queue. (default: 10)tx_stop: The low water mark of free descriptors before we stop tx queue.
(default: 5)
--- drivers/net/ntb_netdev.c | 71 +++++++++++++++++++++++++++++++++++++++++++ drivers/ntb/ntb_transport.c | 20 +++++++++++- include/linux/ntb_transport.h | 1 + 3 files changed, 91 insertions(+), 1 deletion(-)
drivers/net/ntb_netdev.c +71 -0
@@ -61,11 +61,24 @@ MODULE_VERSION(NTB_NETDEV_VER);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_AUTHOR ("Intel Corporation" ); +static unsigned int tx_time =1 ; +module_param (tx_time, uint,0644 ); +MODULE_PARM_DESC (tx_time,"Time in usecs for tx resource reaper" ); + +static unsigned int tx_start =10 ; +module_param (tx_start, uint,0644 ); +MODULE_PARM_DESC (tx_start,"Number of descriptors to free before resume tx" ); + +static unsigned int tx_stop =5 ; +module_param (tx_stop, uint,0644 ); +MODULE_PARM_DESC (tx_stop,"Number of descriptors before stop upper layer tx" ); +struct ntb_netdev {struct list_head list;struct pci_dev *pdev;struct net_device *ndev;struct ntb_transport_qp *qp; +struct timer_list tx_timer; };#define NTB_TX_TIMEOUT_MS 1000
@@ -136,11 +149,39 @@ enqueue_again: } } +static int __ntb_netdev_maybe_stop_tx (struct net_device *netdev, +struct ntb_transport_qp *qp,int size) +{ +struct ntb_netdev *dev =netdev_priv (netdev); + +netif_stop_queue (netdev); +smp_mb (); + +if (likely (ntb_transport_tx_free_entry (qp) < size)) { +mod_timer (&dev->tx_timer, jiffies +usecs_to_jiffies (tx_time)); +return -EBUSY ; + } + +netif_start_queue (netdev); +return 0 ; +} + +static int ntb_netdev_maybe_stop_tx (struct net_device *ndev, +struct ntb_transport_qp *qp,int size) +{ +if (netif_queue_stopped (ndev) || + (ntb_transport_tx_free_entry (qp) >= size)) +return 0 ; + +return __ntb_netdev_maybe_stop_tx (ndev, qp, size); +} +static void ntb_netdev_tx_handler (struct ntb_transport_qp *qp,void *qp_data,void *data,int len) {struct net_device *ndev = qp_data;struct sk_buff *skb; +struct ntb_netdev *dev =netdev_priv (ndev); skb = data;if (!skb || !ndev)
@@ -155,6 +196,12 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data, }dev_kfree_skb (skb); + +if (ntb_transport_tx_free_entry (dev->qp) >= tx_start) { +smp_mb (); +if (netif_queue_stopped (ndev)) +netif_wake_queue (ndev); + } } static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,
@@ -163,10 +210,15 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,struct ntb_netdev *dev =netdev_priv (ndev);int rc; +ntb_netdev_maybe_stop_tx (ndev, dev->qp, tx_stop); + rc =ntb_transport_tx_enqueue (dev->qp, skb, skb->data, skb->len);if (rc) goto err; +/* check for next submit */ +ntb_netdev_maybe_stop_tx (ndev, dev->qp, tx_stop); +return NETDEV_TX_OK ; err:
@@ -175,6 +227,20 @@ err:return NETDEV_TX_BUSY ; } +static void ntb_netdev_tx_timer (unsigned long data) +{ +struct net_device *ndev = (struct net_device *)data; +struct ntb_netdev *dev =netdev_priv (ndev); + +if (ntb_transport_tx_free_entry (dev->qp) < tx_stop) { +mod_timer (&dev->tx_timer, jiffies +msecs_to_jiffies (tx_time)); + }else { +smp_mb (); +if (netif_queue_stopped (ndev)) +netif_wake_queue (ndev); + } +} +static int ntb_netdev_open (struct net_device *ndev) {struct ntb_netdev *dev =netdev_priv (ndev);
@@ -197,8 +263,11 @@ static int ntb_netdev_open(struct net_device *ndev) } } +setup_timer (&dev->tx_timer, ntb_netdev_tx_timer, (unsigned long )ndev); +netif_carrier_off (ndev);ntb_transport_link_up (dev->qp); +netif_start_queue (ndev);return 0 ;
@@ -219,6 +288,8 @@ static int ntb_netdev_close(struct net_device *ndev)while ((skb =ntb_transport_rx_remove (dev->qp, &len)))dev_kfree_skb (skb); +del_timer_sync (&dev->tx_timer); +return 0 ; }
drivers/ntb/ntb_transport.c +19 -1
@@ -487,6 +487,12 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, "tx_index - \t%u\n", qp->tx_index); out_offset +=snprintf (buf + out_offset, out_count - out_offset,"tx_max_entry - \t%u\n" , qp->tx_max_entry); + out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"qp->remote_rx_info->entry - \t%u\n" , + qp->remote_rx_info->entry); + out_offset +=snprintf (buf + out_offset, out_count - out_offset, +"free tx - \t%u\n" , +ntb_transport_tx_free_entry (qp)); out_offset += snprintf(buf + out_offset, out_count - out_offset, "\nQP Link %s\n",
@@ -528,6 +534,7 @@ static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock, } entry = list_first_entry(list, struct ntb_queue_entry, entry);list_del (&entry->entry); + out:spin_unlock_irqrestore (lock, flags);
@@ -1826,7 +1833,7 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data, entry =ntb_list_rm (&qp->ntb_tx_free_q_lock, &qp->tx_free_q);if (!entry) { qp->tx_err_no_buf++; -return -ENOMEM ; +return -EBUSY ; } entry->cb_data = cb;
@@ -1952,6 +1959,17 @@ unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp) }EXPORT_SYMBOL_GPL (ntb_transport_max_size); +#define NTBQ_SPACE (tail, head, size) ((tail) > (head)) ? ((tail) - (head)) : ((size) - (head) + (tail)) + +unsigned int ntb_transport_tx_free_entry (struct ntb_transport_qp *qp) +{ +unsigned int head = qp->tx_index; +unsigned int tail = qp->remote_rx_info->entry; + +return NTBQ_SPACE (tail, head, qp->tx_max_entry); +} +EXPORT_SYMBOL_GPL (ntb_transport_tx_free_entry); +static void ntb_transport_doorbell_callback (void *data,int vector) {struct ntb_transport_ctx *nt = data;
include/linux/ntb_transport.h +1 -0
@@ -83,3 +83,4 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len);void ntb_transport_link_up (struct ntb_transport_qp *qp);void ntb_transport_link_down (struct ntb_transport_qp *qp);bool ntb_transport_link_query (struct ntb_transport_qp *qp); +unsigned int ntb_transport_tx_free_entry (struct ntb_transport_qp *qp);
Signature · 1 line
2.4.0.rc0.43.gcf8a8c6