drivers/net/wan/ixp4xx_hss.c

Source file repositories/reference/linux-study-clean/drivers/net/wan/ixp4xx_hss.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wan/ixp4xx_hss.c
Extension
.c
Size
41445 bytes
Lines
1545
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct net_device_ops hss_hdlc_ops = {
	.ndo_open       = hss_hdlc_open,
	.ndo_stop       = hss_hdlc_close,
	.ndo_start_xmit = hdlc_start_xmit,
	.ndo_siocwandev = hss_hdlc_ioctl,
};

static int ixp4xx_hss_probe(struct platform_device *pdev)
{
	struct of_phandle_args queue_spec;
	struct of_phandle_args npe_spec;
	struct device *dev = &pdev->dev;
	struct net_device *ndev;
	struct device_node *np;
	struct regmap *rmap;
	struct port *port;
	hdlc_device *hdlc;
	int err;
	u32 val;

	/*
	 * Go into the syscon and check if we have the HSS and HDLC
	 * features available, else this will not work.
	 */
	rmap = syscon_regmap_lookup_by_compatible("syscon");
	if (IS_ERR(rmap))
		return dev_err_probe(dev, PTR_ERR(rmap),
				     "failed to look up syscon\n");

	val = cpu_ixp4xx_features(rmap);

	if ((val & (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) !=
	    (IXP4XX_FEATURE_HDLC | IXP4XX_FEATURE_HSS)) {
		dev_err(dev, "HDLC and HSS feature unavailable in platform\n");
		return -ENODEV;
	}

	np = dev->of_node;

	port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
	if (!port)
		return -ENOMEM;

	err = of_parse_phandle_with_fixed_args(np, "intel,npe-handle", 1, 0,
					       &npe_spec);
	if (err)
		return dev_err_probe(dev, err, "no NPE engine specified\n");
	/* NPE ID 0x00, 0x10, 0x20... */
	port->npe = npe_request(npe_spec.args[0] << 4);
	if (!port->npe) {
		dev_err(dev, "unable to obtain NPE instance\n");
		return -ENODEV;
	}

	/* Get the TX ready queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-chl-txready", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no txready queue phandle\n");
	port->txreadyq = queue_spec.args[0];
	/* Get the RX trig queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-chl-rxtrig", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no rxtrig queue phandle\n");
	port->rxtrigq = queue_spec.args[0];
	/* Get the RX queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-pkt-rx", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no RX queue phandle\n");
	port->rxq = queue_spec.args[0];
	/* Get the TX queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-pkt-tx", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no RX queue phandle\n");
	port->txq = queue_spec.args[0];
	/* Get the RX free queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-pkt-rxfree", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no RX free queue phandle\n");
	port->rxfreeq = queue_spec.args[0];
	/* Get the TX done queue as resource from queue manager */
	err = of_parse_phandle_with_fixed_args(np, "intek,queue-pkt-txdone", 1, 0,
					       &queue_spec);
	if (err)
		return dev_err_probe(dev, err, "no TX done queue phandle\n");
	port->txdoneq = queue_spec.args[0];

Annotation

Implementation Notes