Skip to contentSkip to conversation

Generic HDLC interface continued

DISCUSSION Pavel Selivanov 3 participants 3 messages Oct 10, 2002 – Oct 16, 2002

lore
Share & tools
lore
#0 lore raw

Hi.

I'm using hdlc stack for a E1 adapter since Aug. 2001,
and I have some suggestions/questions:
1) I think that hdlc stack should know nothing about my interface type (whether it's V.35, DSL, E1/T1, HPPI, ...).
I'm sure that hdlc stack must provide only protocols support (and a configuration utility to configure protocol's parameters only). All other job is developer's problem (even crc type).

While placing interface type in hdlc struct's isn't good, but to place it in net_device is a good idea (I think).

Possible it's reasonable to make another utility like ethertool (called, for example, e1tool, mdsltool,...) and complementary header (ioctls, structs,...) for configuring interface(for E1: crc4, timeslots,
...), and getting stats.

2) If I've understand author's ideology, he is going to implement hdlc stack "near" current network stack.
I mean hdlc_device appends new fields to net_device, so hdlc device is still the same device as ethernet, and that's fine.

I dont understant what is it for (for this ideology)?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

if.h
struct if_settings

{
        unsigned int type;      /* Type of physical device or protocol */
        union {
                /* {atm/eth/dsl}_settings anyone ? */
                union hdlc_settings ifsu_hdlc;
                union line_settings ifsu_line;
        } ifs_ifsu;
};  
.....
in struct ifreq
                struct  if_settings *ifru_settings;

<<<<<<<<
Is it really necessary ?
At my opinion it would be better to use char *,
and to define it in hdlc.h, hdlc/ioctl.h

3)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

/* For definitions see hdlc.h */

#define IF_IFACE_V35    0x1000          /* V.35 serial interface        */
#define IF_IFACE_V24    0x1001          /* V.24 serial interface        */
#define IF_IFACE_X21    0x1002          /* X.21 serial interface        */
#define IF_IFACE_T1     0x1003          /* T1 telco serial interface    */
#define IF_IFACE_E1     0x1004          /* E1 telco serial interface    */
#define IF_IFACE_SYNC_SERIAL 0x1005     /* cant'b be set by software    */

/* For definitions see hdlc.h */

#define IF_PROTO_HDLC   0x2000          /* raw HDLC protocol            */
#define IF_PROTO_PPP    0x2001          /* PPP protocol                 */
#define IF_PROTO_CISCO  0x2002          /* Cisco HDLC protocol          */
#define IF_PROTO_FR     0x2003          /* Frame Relay protocol         */
#define IF_PROTO_FR_ADD_PVC 0x2004      /*    Create FR PVC             */
#define IF_PROTO_FR_DEL_PVC 0x2005      /*    Delete FR PVC             */
#define IF_PROTO_X25    0x2006          /* X.25                         */

<<<<<<<<<<<

As I understand, it will be never able to make something like ppp-over-framerelay...
But it is widely used, and (for example) negraph in xBSD provide's such functionality...

4)

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
        union {
                struct {
                        fr_proto settings;
                        pvc_device *first_pvc;
                        int pvc_count;

                        struct timer_list timer;
                        int last_poll;
                        int reliable;
                        int changed;
                        int request;
                        int fullrep_sent;
                        u32 last_errors; /* last errors bit list */
                        u8 n391cnt;
                        u8 txseq; /* TX sequence number */
                        u8 rxseq; /* RX sequence number */
                }fr;

                struct {
                        cisco_proto settings;

                        struct timer_list timer;
                        int last_poll;
                        int up;
                        u32 txseq; /* TX sequence number */
                        u32 rxseq; /* RX sequence number */
                }cisco;

                struct {
                        raw_hdlc_proto settings;
                }raw_hdlc;

                struct {
                        struct ppp_device pppdev;
                        struct ppp_device *syncppp_ptr;
                        int (*old_change_mtu)(struct net_device *dev,
                                              int new_mtu);
                }ppp;
        }state; 

<<<<<<<<<<<<<<<

If someone will have to support one more protocol, he have to modify hdlc.h (to add new struct in the union)...
Why don't we do like this:

struct hdlc_proto{
attach
detach
rcv
enslave
void *priv; //Protocol's specific data
char proto_type; //protocol (ppp, fr,...) in a chain struct proto *next;
};
struct hdlc_proto *proto_list;//Supported protocol's list.

typedef struct hdlc_device_struct {
....
struct hdlc_proto *prot; //pointer to current protocol's struct
}

As long as sethdlc tell to hdlc stack: I want ppp-over-fr, hdlc to:
- search proto_list for ppp, search for fr.
- attaches ppp to prot pointer in hdlc_device
- calls fr->attach (which allocated priv pointer)
- calls ppp->attach (which allocates priv pointer)
- calls fr->enslave

This model seems bulki, but It's much more flexible (without changin API, what is very important at my opinion.)

5) It's bad to handle get_stats by hdlc stack.
Some chips provides some info, which I shoud ask(for ifconfig)...

I think hdlc should care own statistics (specific for every protocol).

It's very comfortable in cisco that I have full protocol's info (broadcasts, protocol errors, ...).
Hdlc stack must take no care on HW errors, it's my problem, but it must have it's own statistics.

Sorry for my criticism.
My opinion isn't obsolete, I'm sure I'm wrong in many cases :-) I just want for hdlc stack in Linux to be as usefull as it's possible, and to have a single API (HDLC API changing in second time...).

If I've understant something incorrectle - please tell me.

PS: Sorry for my English.

#1 lore raw

Greetings,

Pavel Selivanov <[email protected]> :
[...]

Quoted 5 lines

1) I think that hdlc stack should know nothing about my interface type (whether it's V.35, DSL, E1/T1, HPPI, ...).
I'm sure that hdlc stack must provide only protocols support (and a configuration utility to configure protocol's parameters only). All other job is developer's problem (even crc type).

Then every driver must implement it's own ioctl() and utility. Ahum...

[...]

Quoted 4 lines

Possible it's reasonable to make another utility like ethertool (called, for example, e1tool, mdsltool,...) and complementary header (ioctls, structs,...) for configuring interface(for E1: crc4, timeslots,
...), and getting stats.

mv sethdlc.c hdlctool.c ?

Quoted 4 lines

2) If I've understand author's ideology, he is going to implement hdlc stack "near" current network stack.
I mean hdlc_device appends new fields to net_device, so hdlc device is still the same device as ethernet, and that's fine.

I'd rather have hdlc_device pointing to it's own net_device instead of embedding it directly but I won't fight too much about this (so far :o) ).

[struct if_settings and friends]

Quoted 1 line

Is it really necessary ?

Yes, it's used. It may/will be done slightly differently.

Quoted 1 line

At my opinion it would be better to use char *,

It provides less type-checking at compile time.

Quoted 1 line

and to define it in hdlc.h, hdlc/ioctl.h

{hdlc/line}_settings are defined in hdlc/ioctl.h
Others layer 2 protocols may use if_settings (they don't seem to be in a hurry though :o) ).

[include/linux/if.h - IF_IFACE_XYZ/IF_PROTO_ABC]

Quoted 4 lines

As I understand, it will be never able to make something like ppp-over-framerelay...
But it is widely used, and (for example) negraph in xBSD provide's such functionality...

Imho hacking drivers/net/wan/hdlc_fr.c::fr_rx() and hdlc/ioctl.h isn't the hardest part of ppp-over-fr for those who really need it.

[struct hdlc_device]

Quoted 2 lines

If someone will have to support one more protocol, he have to modify hdlc.h (to add new struct in the union)...

Do you have a specific protocol in mind ?

Quoted 1 line

Why don't we do like this:

[snip, snip]

Admitting there is a heap of ppp-over-fr code waiting to be included and even if someone is ready to code this all, I'm for a lazyer solution. :o)

Signature · 1 line
Ueimor
#2 lore raw
In reply to Pavel Selivanov
Quoted 3 lines · Pavel Selivanov

I'm sure that hdlc stack must provide only protocols support (and a configuration utility to configure protocol's parameters only). All other job is developer's problem (even crc type).

That's what the code does - the hdlc_*.c code knows only protocol ioctls, and passes other things straight to hardware driver.

But the interface (structure definitions) must be the same for all devices, as we don't want different tools for different cards.

Quoted 2 lines

While placing interface type in hdlc struct's isn't good, but to place it in net_device is a good idea (I think).

I don't think so. Most cards (not necesarilly WAN ones) have only one interface (type).

Quoted 4 lines

2) If I've understand author's ideology, he is going to implement hdlc stack "near" current network stack.
I mean hdlc_device appends new fields to net_device, so hdlc device is still the same device as ethernet, and that's fine.

I used to think of it as of inherited structure from, say, C++.

Quoted 15 lines

I dont understant what is it for (for this ideology)?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

if.h
struct if_settings

{
        unsigned int type;      /* Type of physical device or protocol */
        union {
                /* {atm/eth/dsl}_settings anyone ? */
                union hdlc_settings ifsu_hdlc;
                union line_settings ifsu_line;
        } ifs_ifsu;
};  
.....
in struct ifreq
                struct  if_settings *ifru_settings;
Quoted 3 lines

<<<<<<<<
Is it really necessary ?
At my opinion it would be better to use char *,

It was done that way at some point and then redesigned, but now I think we should rather use just a union of struct pointers.

The hdlc/ioctl.h may seem to be a little overkill, I understand the definitions are there for performance reasons (while building the kernel).

Quoted 2 lines

If someone will have to support one more protocol, he have to modify hdlc.h (to add new struct in the union)...

Yes.

Quoted 9 lines

As long as sethdlc tell to hdlc stack: I want ppp-over-fr, hdlc to:
- search proto_list for ppp, search for fr.
- attaches ppp to prot pointer in hdlc_device
- calls fr->attach (which allocated priv pointer)
- calls ppp->attach (which allocates priv pointer)
- calls fr->enslave

This model seems bulki, but It's much more flexible (without changin API, what is very important at my opinion.)

That's not about changing API, that's only adding _new_ parts to the API, it doesn't break anything. Anyway, the current code:
- exist
- is quite simple and thus reliable
- does the job.
So I'm not going to spend time on changing it once again, except for the union change mentioned earlier (a cosmetic change).

Quoted 2 lines

5) It's bad to handle get_stats by hdlc stack.
Some chips provides some info, which I shoud ask(for ifconfig)...

hdlc_* basically only increments rx_errors counter... We could drop the get_stats() (move it to hw drivers) when we have a driver which needs that. It's not a problem, it doesn't really change anything.

Quoted 2 lines

It's very comfortable in cisco that I have full protocol's info (broadcasts, protocol errors, ...).

Cisco = IOS software or Cisco = protocol?
Yes, it would be better to have another set of stats for hw and another one for upper layers. That's true for most interface types, not only WAN HDLC-like ones.

Or should we add new fields to existing struct? Possibly.

Quoted 3 lines

I just want for hdlc stack in Linux to be as usefull as it's possible, and to have a single API (HDLC API changing in second time...).

That's exactly what I want, too.

Signature · 2 lines
Krzysztof Halasa
Network Administrator