Marc Kleine-Budde wrote:

> here "./strip-src -m -i -v 2.6.31" version of the at91 driver,


> The driver with NAPI receiving messages with a length of 1 on a 1 Mbit
> link without swapping the messages (tested with pengutronix cansequence).
> However if I add some "ping -f" load the driver keeps working (tested
> with looking at the data bytes in the driver), but the userspace doesn't
> get enough cpu cycles so AFAICS the pacakges must be dropped in the
> network layer.

You may try to increase the socket receivce buffer which helped us in a real
world project, when logging 5 CAN busses in a vehicle ...

In the candump tool there is a commandline option '-r <size>' for that, which
makes:

                if (setsockopt(s[i], SOL_SOCKET, SO_RCVBUF,
                               &rcvbuf_size, sizeof(rcvbuf_size)) < 0) {
                        perror("setsockopt SO_RCVBUF");
                        exit(1);
                }

We did not had any drops after this change, as the userspace app finally got
enough CPU time and pulled big chunks of can_frames from the receiving socket.


> 
> Even on the 1 Mbit link the total number IRQs isn't reduced by NAPI
> (less than 1%). But with NAPI I can enable the Acknowledgement Error
> even on 1 Mbit, and the system doesn't lock up. It generated ~15K Int/s.
> 
> Adding again "ping -f" load, the CAN interrupts drop to ~11K Int/s,
> the Ethernet causes only ~7K Int/s.


The max. (theoretical) frame rate is 21.276 frames/s when we take a
minimum length frame (47 bits) this is 47usecs on 1MBit/s.

IMO in real environments you'll get something between 2000 - 5000 frames/s.

And for that reason we need to check how much effort we should spend on this
topic and how other people e.g. dealing with Gigabit Ethernet controllers work
on this.

See:

Intel Corporation: Interrupt Moderation Using Intel? GbE Controllers
http://download.intel.com/design/network/applnots/ap450.pdf.

Btw. i really appreciate the NAPI stuff.

> 
> Maybe we can think of some really "slow" polling for such interrupts.
> IIRC the SJA1000 has the same problem.
> 
> Here's the driver, comments welcome. There are some functions, that
> might be moved out of the driver into can/dev.c (alloc_can*frame).

(..)

> +
> +static struct sk_buff *
> +alloc_can_frame(struct net_device *dev, struct can_frame **cf)
> +{
> +     struct sk_buff *skb;
> +
> +     skb = netdev_alloc_skb(dev, sizeof(struct can_frame));
> +     if (unlikely(!skb))
> +             return NULL;
> +
> +     skb->protocol = htons(ETH_P_CAN);
> +     skb->ip_summed = CHECKSUM_UNNECESSARY;
> +     *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
> +
> +     return skb;
> +}
> +
> +
> +static struct sk_buff *
> +alloc_can_err_frame(struct net_device *dev, struct can_frame **cf)
> +{
> +     struct sk_buff *skb;
> +
> +     skb = alloc_can_frame(dev, cf);
> +     if (unlikely(!skb))
> +             return NULL;
> +
> +     memset(*cf, 0, sizeof(struct can_frame));
> +     (*cf)->can_id = CAN_ERR_FLAG;
> +     (*cf)->can_dlc = CAN_ERR_DLC;
> +
> +     return skb;
> +}

Good idea to bring in some of theses convenience functions.
But i would prefer creating some static inline definitions in dev.h
Some EXPORT_SYMBOL_GPL() seems too heavy wight for that.

Regards,
Oliver
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to