Skip to content

Commit

Permalink
Merge branch 'ethernet-over-hdlc'
Browse files Browse the repository at this point in the history
David Gounaris says:

====================
Ethernet over hdlc
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 4, 2018
2 parents 68ddc82 + ccb7bc0 commit 802869f
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
Original file line number Diff line number Diff line change
@@ -98,6 +98,12 @@ The property below is dependent on fsl,tdm-interface:
usage: optional for tdm interface
value type: <empty>
Definition : Internal loopback connecting on TDM layer.
- fsl,hmask
usage: optional
Value type: <u16>
Definition: HDLC address recognition. Set to zero to disable
address filtering of packets:
fsl,hmask = /bits/ 16 <0x0000>;

Example for tdm interface:

26 changes: 24 additions & 2 deletions drivers/net/wan/fsl_ucc_hdlc.c
Original file line number Diff line number Diff line change
@@ -97,6 +97,12 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
if (priv->tsa) {
uf_info->tsa = 1;
uf_info->ctsp = 1;
uf_info->cds = 1;
uf_info->ctss = 1;
} else {
uf_info->cds = 0;
uf_info->ctsp = 0;
uf_info->ctss = 0;
}

/* This sets HPM register in CMXUCR register which configures a
@@ -265,7 +271,7 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
iowrite16be(MAX_FRAME_LENGTH, &priv->ucc_pram->mflr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfthr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfcnt);
iowrite16be(DEFAULT_ADDR_MASK, &priv->ucc_pram->hmask);
iowrite16be(priv->hmask, &priv->ucc_pram->hmask);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr1);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr2);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr3);
@@ -375,6 +381,10 @@ static netdev_tx_t ucc_hdlc_tx(struct sk_buff *skb, struct net_device *dev)
dev->stats.tx_bytes += skb->len;
break;

case ARPHRD_ETHER:
dev->stats.tx_bytes += skb->len;
break;

default:
dev->stats.tx_dropped++;
dev_kfree_skb(skb);
@@ -512,6 +522,7 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
break;

case ARPHRD_PPP:
case ARPHRD_ETHER:
length -= HDLC_CRC_SIZE;

skb = dev_alloc_skb(length);
@@ -780,6 +791,7 @@ static int ucc_hdlc_attach(struct net_device *dev, unsigned short encoding,

if (parity != PARITY_NONE &&
parity != PARITY_CRC32_PR1_CCITT &&
parity != PARITY_CRC16_PR0_CCITT &&
parity != PARITY_CRC16_PR1_CCITT)
return -EINVAL;

@@ -987,11 +999,17 @@ static const struct dev_pm_ops uhdlc_pm_ops = {
#define HDLC_PM_OPS NULL

#endif
static void uhdlc_tx_timeout(struct net_device *ndev)
{
netdev_err(ndev, "%s\n", __func__);
}

static const struct net_device_ops uhdlc_ops = {
.ndo_open = uhdlc_open,
.ndo_stop = uhdlc_close,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = uhdlc_ioctl,
.ndo_tx_timeout = uhdlc_tx_timeout,
};

static int ucc_hdlc_probe(struct platform_device *pdev)
@@ -1015,7 +1033,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
}

ucc_num = val - 1;
if ((ucc_num > 3) || (ucc_num < 0)) {
if (ucc_num > (UCC_MAX_NUM - 1) || ucc_num < 0) {
dev_err(&pdev->dev, ": Invalid UCC num\n");
return -EINVAL;
}
@@ -1090,6 +1108,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
goto free_utdm;
}

if (of_property_read_u16(np, "fsl,hmask", &uhdlc_priv->hmask))
uhdlc_priv->hmask = DEFAULT_ADDR_MASK;

ret = uhdlc_init(uhdlc_priv);
if (ret) {
dev_err(&pdev->dev, "Failed to init uhdlc\n");
@@ -1107,6 +1128,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
hdlc = dev_to_hdlc(dev);
dev->tx_queue_len = 16;
dev->netdev_ops = &uhdlc_ops;
dev->watchdog_timeo = 2 * HZ;
hdlc->attach = ucc_hdlc_attach;
hdlc->xmit = ucc_hdlc_tx;
netif_napi_add(dev, &uhdlc_priv->napi, ucc_hdlc_poll, 32);
1 change: 1 addition & 0 deletions drivers/net/wan/fsl_ucc_hdlc.h
Original file line number Diff line number Diff line change
@@ -106,6 +106,7 @@ struct ucc_hdlc_private {

unsigned short encoding;
unsigned short parity;
unsigned short hmask;
u32 clocking;
spinlock_t lock; /* lock for Tx BD and Tx buffer */
#ifdef CONFIG_PM

0 comments on commit 802869f

Please sign in to comment.