Commit 76d94b23 authored by Tomoya's avatar Tomoya Committed by David S. Miller

pch_can: Add flow control processing

Currently, there is no flow control processing.
Thus, Add flow control processing as
when there is no empty of tx buffer,
netif_stop_queue is called.
When there is empty buffer, netif_wake_queue is called.
Signed-off-by: default avatarTomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 249fab77
...@@ -102,6 +102,10 @@ ...@@ -102,6 +102,10 @@
#define PCH_FIFO_THRESH 16 #define PCH_FIFO_THRESH 16
/* TxRqst2 show status of MsgObjNo.17~32 */
#define PCH_TREQ2_TX_MASK (((1 << PCH_TX_OBJ_NUM) - 1) <<\
(PCH_RX_OBJ_END - 16))
enum pch_ifreg { enum pch_ifreg {
PCH_RX_IFREG, PCH_RX_IFREG,
PCH_TX_IFREG, PCH_TX_IFREG,
...@@ -871,6 +875,8 @@ static int pch_can_rx_poll(struct napi_struct *napi, int quota) ...@@ -871,6 +875,8 @@ static int pch_can_rx_poll(struct napi_struct *napi, int quota)
dlc = 8; dlc = 8;
stats->tx_bytes += dlc; stats->tx_bytes += dlc;
stats->tx_packets++; stats->tx_packets++;
if (int_stat == PCH_TX_OBJ_END)
netif_wake_queue(ndev);
} }
int_stat = pch_can_int_pending(priv); int_stat = pch_can_int_pending(priv);
...@@ -1009,18 +1015,6 @@ static int pch_close(struct net_device *ndev) ...@@ -1009,18 +1015,6 @@ static int pch_close(struct net_device *ndev)
return 0; return 0;
} }
static int pch_get_msg_obj_sts(struct net_device *ndev, u32 obj_id)
{
u32 buffer_status = 0;
struct pch_can_priv *priv = netdev_priv(ndev);
/* Getting the message object status. */
buffer_status = (u32) pch_can_get_buffer_status(priv);
return buffer_status & obj_id;
}
static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
{ {
int i, j; int i, j;
...@@ -1031,17 +1025,16 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -1031,17 +1025,16 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
if (can_dropped_invalid_skb(ndev, skb)) if (can_dropped_invalid_skb(ndev, skb))
return NETDEV_TX_OK; return NETDEV_TX_OK;
if (priv->tx_obj == PCH_TX_OBJ_END) { /* Point tail Obj */ if (priv->tx_obj == PCH_TX_OBJ_END) {
while (pch_get_msg_obj_sts(ndev, (((1 << PCH_TX_OBJ_NUM)-1) << if (ioread32(&priv->regs->treq2) & PCH_TREQ2_TX_MASK)
PCH_RX_OBJ_NUM))) netif_stop_queue(ndev);
udelay(500);
priv->tx_obj = PCH_TX_OBJ_START; /* Point head of Tx Obj ID */ tx_buffer_avail = priv->tx_obj;
tx_buffer_avail = priv->tx_obj; /* Point Tail of Tx Obj */ priv->tx_obj = PCH_TX_OBJ_START;
} else { } else {
tx_buffer_avail = priv->tx_obj; tx_buffer_avail = priv->tx_obj;
priv->tx_obj++;
} }
priv->tx_obj++;
/* Reading the Msg Obj from the Msg RAM to the Interface register. */ /* Reading the Msg Obj from the Msg RAM to the Interface register. */
iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[1].cmask); iowrite32(PCH_CMASK_RX_TX_GET, &priv->regs->ifregs[1].cmask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment