Re: Traffic shaping in the driver.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This doesn't really belong on linux-net, follow-ups are welcome to remove
that list, IMO.

Vinay Vernekar wrote:
> I am developing a driver for ADSL modem. I need to implement traffic
> shaping with a certain upstream bit rate. Can anyone suggest how is
> this done. I want to know what calls I have to use for this purpose. It
> will be helpful if anybody can tell an already existing driver where it
> is done.

Look at pretty much any ATM driver for example code, at least if your
card supports shaping in hardware.

When your driver's ->open(vcc,vpi,vci) method is called on a vcc, you can
inspect the requested QoS in vcc->qos.  Specifically, you'd do something
like:

	switch (vcc->qos.txtp.traffic_class) {
	case ATM_UBR:
		mydriver_no_qos_requested();
		break;
	case ATM_CBR:
		pcr = atm_pcr_goal(&vcc->qos.txtp);
		if (pcr == 0)
			pcr = MYDRIVER_MAXIMUM_CELLS_PER_SECOND;
		if (pcr < 0)	/* This means round donw, technically */
			pcr = -pcr;
		mydriver_cbr_tx_cells_per_sec(pcr);
		break;
	default:		/* Unsupported QoS type */
		return -EINVAL;
	}

Obviously fill in mydriver_*() with whatever code your device needs to
set up hardware shaping on that vcc.  atm_pcr_goal() is a utility
function provided in net/atm/atm_misc.c -- look at the documentation there.

If your card does not support hardware shaping then you'd need to
look at the higher level stuff like network schedulers and such.
I'd be really surprised if this was the case, though -- for optimum
performance the DSL modem's SAR chip  has to provide cells with the
right gap to keep the small buffer on the PHY chip happy, so it
almost certainly has at least rudimentary hardware shaping support.

There's also a ->change_qos() entry point which can be called to
modify the QoS of an open vcc.  It's optional to implement and
rarely used in these types of applications, so I wouldn't worry about
it right away.

-Mitch
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.rutgers.edu


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux