[dpdk-dev] [PATCH] kni: fix igb and ixgbe kni ethtool get_link op

2015-04-03 Thread Shelton Chia
igb and ixgbe's link detected always return yes, fix get_link func
refer to get_settings, it works correctly for my i350 and 82599es nic.

Signed-off-by: Shelton Chia 
---
 .../linuxapp/kni/ethtool/igb/igb_ethtool.c | 18 ++-
 .../linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c | 26 +-
 2 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c 
b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c
index f3c48b2..5457f48 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/igb/igb_ethtool.c
@@ -383,19 +383,15 @@ static int igb_set_settings(struct net_device *netdev, 
struct ethtool_cmd *ecmd)
 static u32 igb_get_link(struct net_device *netdev)
 {
struct igb_adapter *adapter = netdev_priv(netdev);
-   struct e1000_mac_info *mac = &adapter->hw.mac;
+   struct e1000_hw *hw = &adapter->hw;
+   u32 status;

-   /*
-* If the link is not reported up to netdev, interrupts are disabled,
-* and so the physical link state may have changed since we last
-* looked. Set get_link_status to make sure that the true link
-* state is interrogated, rather than pulling a cached and possibly
-* stale link state from the driver.
-*/
-   if (!netif_carrier_ok(netdev))
-   mac->get_link_status = 1;
+   status = E1000_READ_REG(hw, E1000_STATUS);

-   return igb_has_link(adapter);
+   if (status & E1000_STATUS_LU) 
+   return 1;
+   else
+   return 0;
 }

 static void igb_get_pauseparam(struct net_device *netdev,
diff --git a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c 
b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c
index 11472bd..184b14f 100644
--- a/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c
+++ b/lib/librte_eal/linuxapp/kni/ethtool/ixgbe/ixgbe_ethtool.c
@@ -801,6 +801,30 @@ static void ixgbe_get_regs(struct net_device *netdev, 
struct ethtool_regs *regs,
regs_buff[1128] = IXGBE_READ_REG(hw, IXGBE_MFLCN);
 }

+static u32 ixgbe_get_link(struct net_device *netdev)
+{
+   struct ixgbe_adapter *adapter = netdev_priv(netdev);
+   struct ixgbe_hw *hw = &adapter->hw;
+   u32 link_speed = 0;
+   bool link_up;
+
+   if (!in_interrupt()) {
+   hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
+   } else {
+   /*
+* this case is a special workaround for RHEL5 bonding
+* that calls this routine from interrupt context
+*/
+   link_speed = adapter->link_speed;
+   link_up = adapter->link_up;
+   }
+
+   if (link_up) 
+   return 1;
+   else 
+   return 0;
+}
+
 static int ixgbe_get_eeprom_len(struct net_device *netdev)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
@@ -2838,7 +2862,7 @@ struct ethtool_ops ixgbe_ethtool_ops = {
.get_wol= ixgbe_get_wol,
.set_wol= ixgbe_set_wol,
.nway_reset = ixgbe_nway_reset,
-   .get_link   = ethtool_op_get_link,
+   .get_link   = ixgbe_get_link,
.get_eeprom_len = ixgbe_get_eeprom_len,
.get_eeprom = ixgbe_get_eeprom,
.set_eeprom = ixgbe_set_eeprom,
-- 
2.3.5



[dpdk-dev] [RFC PATCH 0/6] DPDK support to bifurcated driver

2015-04-20 Thread Shelton Chia
Hi,
I can receive packets when I mmaped all pci memory not only rx and tx
desc.

2015-04-09 11:43 GMT+08:00 ??? :

> Hi Cunming,
>  I applyed bifurc dirver patches and tested it follow your example.
> But I can't received packets with testpmd and l2fwd.
> Kernel stack can receive packets from 10.0.0.2 before "ethtool -N
> XGE4.1 flow-type ip4 src-ip 10.0.0.2 action 12". After "thtool -N XGE4.1
> flow-type ip4 src-ip 10.0.0.2 action 12", kernel stack can't receive
> packets from 10.0.0.2, but testpmd and l2fwd cannot receive any packets
> too.
>queue 0-11 used by kernel and queue 12 used by bifurc dirver.
>How can I make it work?
>
> 2014-11-25 22:11 GMT+08:00 Cunming Liang :
>
>>
>> This is a RFC patch set to support "bifurcated driver" in DPDK.
>>
>>
>> What is "bifurcated driver"?
>> ===
>>
>> The "bifurcated driver" stands for the kernel NIC driver that supports:
>>
>> 1. on-demand rx/tx queue pairs split-off and assignment to user space
>>
>> 2. direct NIC resource(e.g. rx/tx queue registers) access from user space
>>
>> 3. distributing packets to kernel or user space rx queues by
>>NIC's flow director according to the filter rules
>>
>> Here's the kernel patch set to support.
>> http://comments.gmane.org/gmane.linux.network/333615
>>
>>
>> Usage scenario
>> =
>>
>> It's well accepted by industry to use DPDK to process fast path packets in
>> user space in a high performance fashion, meanwhile processing slow path
>> control packets in kernel space is still needed as those packets usually
>> rely on in_kernel TCP/IP stacks and/or socket programming interface.
>>
>> KNI(Kernel NIC Interface) mechanism in DPDK is designed to meet this
>> requirement, with below limitation:
>>
>>   1) Software classifies packets and distributes them to kernel via DPDK
>>  software rings, at the cost of significant CPU cycles and memory
>> bandwidth.
>>
>>   2) Memory copy packets between kernel' socket buffer and mbuf brings
>>  significant negative performance impact to KNI performance.
>>
>> The bifurcated driver provides a alternative approach that not only
>> offloads
>> flow classification and distribution to NIC but also support packets
>> zero_copy.
>>
>> User can use standard ethtool to add filter rules to the NIC in order to
>> distribute specific flows to the queues only accessed by kernel driver and
>> stack, and add other rules to distribute packets to the queues assigned to
>> user-space.
>>
>> For those rx/tx queue pairs that directly accessed from user space,
>> DPDK takes over the packets rx/tx as well as corresponding DMA operation
>> for high performance packet I/O.
>>
>>
>> What's the impact and change to DPDK
>> ==
>>
>> DPDK usually binds PCIe NIC devices by leveraging kernel' user space
>> driver
>> mechanism UIO or VFIO to map entire NIC' PCIe I/O space of NIC to user
>> space.
>> The bifurcated driver PMD talks to a NIC interface using raw socket APIs
>> and
>> only mmap() limited I/O space (e.g. certain 4K pages) for accessing
>> involved
>> rx/tx queue pairs. So the impact and changes mainly comes with below:
>>
>> - netdev
>> DPDK needs to create a af_packet socket and bind it to a bifurcated
>> netdev.
>> The socket fd will be used to request 'queue pairs info',
>> 'split/return queue pairs' and etc. The PCIe device ID, netdev MAC
>> address,
>> numa info are also from the netdev response.
>>
>> - PCIe device scan and driver probe
>> netdev provides the PCIe device ID information. Refer to the device
>> ID,
>> the correct driver should be used. And for such netdev device, the
>> creation
>> of PCIe device is no longer from scan but the on-demand assignment.
>>
>> - PCIe BAR mapping
>> "bifurcated driver" maps several pages for the queue pairs.
>> Others BAR register space maps to a fake page. The BAR mapping go
>> through
>> mmap on sockfd. Which is a little different from what UIO/VFIO does.
>>
>> - PMD
>> The PMD will no longer really initialize and configure NIC.
>> Instead, it only takes care the queue pair setup, rx_burst and
>> tx_burst.
>>
>> The patch uses eal '--vdev' parameter to assign netdev iface name and
>> number of
>> queue pairs. Here's a example about how to configure the bifurcated
>> driver and
>> run DPDK testpmd with bifurcated PMD.
>>
>>   1. Set promisc mode
>>   > ifconfig eth0 promisc
>>
>>   2. Turn on fdir
>>   > ethtool -K eth0 ntuple on
>>
>>   3. Setup a flow director rule to distribute packets with source ip
>>  0.0.0.0 to rxq No.0
>>   > ethtool -N eth0  flow-type udp4 src-ip 0.0.0.0 action 0
>>
>>   4. Run testpmd on netdev 'eth0' with 1 queue pair.
>>   > ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 \
>>   >  --vdev=rte_bifurc,iface=eth0,qpairs=1 -- \
>>   >  -i --rxfreet=32 --txfreet=32 --txrst=32
>>   Note:
>> iface and qpairs arguments above specify the netdev interface name and
>> nu

[dpdk-dev] [PATCH] librte_pmd_e1000: power down the serdes link

2015-03-07 Thread Shelton Chia
Signed-off-by: Shelton Chia 
---
 lib/librte_pmd_e1000/igb_ethdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_e1000/igb_ethdev.c 
b/lib/librte_pmd_e1000/igb_ethdev.c
index 504ae74..314ef2a 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -948,7 +948,10 @@ eth_igb_stop(struct rte_eth_dev *dev)
}

/* Power down the phy. Needed to make the link go Down */
-   e1000_power_down_phy(hw);
+   if (hw->phy.media_type == e1000_media_type_copper)
+   e1000_power_down_phy(hw);
+   else
+   e1000_shutdown_fiber_serdes_link(hw);

igb_dev_clear_queues(dev);

-- 
2.3.0



[dpdk-dev] [PATCH] ixgbe: fix LSC callback

2015-09-01 Thread Shelton Chia
add _rte_eth_dev_callback_process to call callback func

Signed-off-by: Shelton Chia 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b8ee1e9..4e4c118 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -2775,6 +2775,8 @@ ixgbe_dev_interrupt_action(struct rte_eth_dev *dev)

ixgbe_dev_link_status_print(dev);

+   __rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
+
intr_enable_delay = true;
}

-- 
2.5.0