author | Sandeep Paulraj <s-paulraj@ti.com> | |
Thu, 13 Sep 2012 15:33:05 +0000 (11:33 -0400) | ||
committer | Murali Karicheri <m-karicheri2@ti.com> | |
Wed, 3 Dec 2014 16:29:33 +0000 (11:29 -0500) | ||
commit | e86eb83e37a5b46def3dbd3b58dfb45ec0e7bf03 | |
tree | 510ff7a7d3afbd2b9844240b51eae8f67f37fd72 | tree | snapshot (tar.xz tar.gz zip) |
parent | 2953d2c9838a779b08c9a2eceac6279bd7ec4b3f | commit | diff |
net:keystone: add net core driver
s commit adds an ethernet driver for keystone devices which exposes the
standard netdev operations.
The specifics on the device tree bindings for Keystone Network support
can be found in:
Documentation/devicetree/bindings/net/keystone-net.txt
The network driver sets up the streaming switch interface to route all
packets to PDSP0. At present this is the only mode that is supported
by the driver. In the near future we intend to add a feature in the driver
which will enable a user to bypass the PA.
The SGMII ports need to be initialized and appropriately configured.
SERDES initialization also needs to done. These APIs are found in
keystone_sgmii.c
The switch and the mac sliver ports need to be configured. In the
switch we enable all statistics to be collected. All ports of the
ALE are put in the forward mode.
A private structure is maintained which stores the dma channels and dma
channel names and rx state. The platform device and network device are also
stored in this privare structure
each packet has a structure(called netcp_packet) associated with it. This
comprises of a scatterl;ist array, the number of scatterlist entries, the
status of the dma and the dma cookie. A pomiter to the skb is also stored in
this structure.
Model:
1) Open:
On device open, we request DMA channels using standard dma engine APIs
provided by the dmaengine layer. The capabilities of the DMA are
appropriately
set and the appropriate channels are requested by name. We invoke the
dma_request_channel_by_name API to acquire dma engine channels. The netdev
open also sets up the streaming switch, SGMII, Serdes, switch and mac
sliver.
Finally we configure the PA
2) Stop:
A standard netdev stop operation stops the netif queue. It sets the receive
state to teardown and calls dmaengine_pause APIs from the dmaengine layer to
pause both the RX and TX channel. After NAPI is disabled, the operation goes
onto release the dma channels by calling the dma_release_channel API.
The RX state is set to invalid and the ethernet susbsystem is stopped
3) Polling
A NAPI poll function is implemented. which sets the RX state to poll and
resume the dma engine. It will then go onto initialize the queues.
We allocate memory for each packet and initialize the scatterlist.
We iterate in a loop till we run out memory for the descriptors.These
dma descriptors are acquired using a dmaengine API called
device_prep_slave_sg. We pass appropriate arguments to the API. At this
instant we are not concerned about the Software info and PS info associated
with each descriptor. We use a single scatterlist associated with each
packet.
netcp_rx_complete is the callback associated with the dma engine on the RX
side. The callback function checks for the correct DMA and RX state and
warns
the user on seeing abnormal behavior. It then goes onto stahs the received
packet to the tail of a linked list.
4) Xmit
netcp_ndo_start_xmit is the stanndard netdev operation that is used to push
an
outgoing packet. Again we have a structure for each packet. This will
contain
an array of scatterlists and the number of scatterlist entries which at this
point should be 1. We then call the device_prep_slave_sg API with
appropriate
parameters to acquire a descriptor for the TX operation. 'netcp_tx_complete'
is the callback fucntion attached to each TX dma callback. All the network
statistics are appropriately updated on a successful transfer. The callback
then proceeds to free the skb with the dev_kfree_skb_any API.
5) Receive
In the napi_poll netdev operation, we call the netcp_refill_rx function
which
will allocate skbs and attch these skbs to a descriptor until we run out of
descriptor memory. the deliver_stash routine fills the appropriate RX
statictics and send the skb up the stack.
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
net:keystone: add device tree bindings for keystone net core engine
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
net: vlan: rename NETIF_F_HW_VLAN_
s commit adds an ethernet driver for keystone devices which exposes the
standard netdev operations.
The specifics on the device tree bindings for Keystone Network support
can be found in:
Documentation/devicetree/bindings/net/keystone-net.txt
The network driver sets up the streaming switch interface to route all
packets to PDSP0. At present this is the only mode that is supported
by the driver. In the near future we intend to add a feature in the driver
which will enable a user to bypass the PA.
The SGMII ports need to be initialized and appropriately configured.
SERDES initialization also needs to done. These APIs are found in
keystone_sgmii.c
The switch and the mac sliver ports need to be configured. In the
switch we enable all statistics to be collected. All ports of the
ALE are put in the forward mode.
A private structure is maintained which stores the dma channels and dma
channel names and rx state. The platform device and network device are also
stored in this privare structure
each packet has a structure(called netcp_packet) associated with it. This
comprises of a scatterl;ist array, the number of scatterlist entries, the
status of the dma and the dma cookie. A pomiter to the skb is also stored in
this structure.
Model:
1) Open:
On device open, we request DMA channels using standard dma engine APIs
provided by the dmaengine layer. The capabilities of the DMA are
appropriately
set and the appropriate channels are requested by name. We invoke the
dma_request_channel_by_name API to acquire dma engine channels. The netdev
open also sets up the streaming switch, SGMII, Serdes, switch and mac
sliver.
Finally we configure the PA
2) Stop:
A standard netdev stop operation stops the netif queue. It sets the receive
state to teardown and calls dmaengine_pause APIs from the dmaengine layer to
pause both the RX and TX channel. After NAPI is disabled, the operation goes
onto release the dma channels by calling the dma_release_channel API.
The RX state is set to invalid and the ethernet susbsystem is stopped
3) Polling
A NAPI poll function is implemented. which sets the RX state to poll and
resume the dma engine. It will then go onto initialize the queues.
We allocate memory for each packet and initialize the scatterlist.
We iterate in a loop till we run out memory for the descriptors.These
dma descriptors are acquired using a dmaengine API called
device_prep_slave_sg. We pass appropriate arguments to the API. At this
instant we are not concerned about the Software info and PS info associated
with each descriptor. We use a single scatterlist associated with each
packet.
netcp_rx_complete is the callback associated with the dma engine on the RX
side. The callback function checks for the correct DMA and RX state and
warns
the user on seeing abnormal behavior. It then goes onto stahs the received
packet to the tail of a linked list.
4) Xmit
netcp_ndo_start_xmit is the stanndard netdev operation that is used to push
an
outgoing packet. Again we have a structure for each packet. This will
contain
an array of scatterlists and the number of scatterlist entries which at this
point should be 1. We then call the device_prep_slave_sg API with
appropriate
parameters to acquire a descriptor for the TX operation. 'netcp_tx_complete'
is the callback fucntion attached to each TX dma callback. All the network
statistics are appropriately updated on a successful transfer. The callback
then proceeds to free the skb with the dev_kfree_skb_any API.
5) Receive
In the napi_poll netdev operation, we call the netcp_refill_rx function
which
will allocate skbs and attch these skbs to a descriptor until we run out of
descriptor memory. the deliver_stash routine fills the appropriate RX
statictics and send the skb up the stack.
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
net:keystone: add device tree bindings for keystone net core engine
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
net: vlan: rename NETIF_F_HW_VLAN_
Documentation/devicetree/bindings/net/keystone-net.txt | [new file with mode: 0644] | blob |
drivers/net/ethernet/ti/Kconfig | diff | blob | history | |
drivers/net/ethernet/ti/Makefile | diff | blob | history | |
drivers/net/ethernet/ti/keystone_net.h | [new file with mode: 0644] | blob |
drivers/net/ethernet/ti/keystone_net_core.c | [new file with mode: 0644] | blob |