Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1328538 > unrolled thread

[PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs

Started byLuis Henriques <luis.henriques@canonical.com>
First post2016-02-07 18:40 +0100
Last post2016-02-08 23:20 +0100
Articles 9 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques <luis.henriques@canonical.com> - 2016-02-07 18:40 +0100
    [PATCH 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h> Luis Henriques <luis.henriques@canonical.com> - 2016-02-07 18:40 +0100
    [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques <luis.henriques@canonical.com> - 2016-02-07 18:50 +0100
      Re: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from  <linux/if_ether.h> Joe Perches <joe@perches.com> - 2016-02-07 20:40 +0100
        Re: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from  <linux/if_ether.h> Luis Henriques <luis.henriques@canonical.com> - 2016-02-08 23:10 +0100
    [PATCH 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h> Luis Henriques <luis.henriques@canonical.com> - 2016-02-07 18:50 +0100
    [PATCH 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h> Luis Henriques <luis.henriques@canonical.com> - 2016-02-07 18:50 +0100
    Re: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of  network data structs Geert Uytterhoeven <geert@linux-m68k.org> - 2016-02-08 09:40 +0100
      Re: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of  network data structs Luis Henriques <luis.henriques@canonical.com> - 2016-02-08 23:20 +0100

#1328538 — [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-07 18:40 +0100
Subject[PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
Message-ID<qZBtx-Xv-31@gated-at.bofh.it>
Several network-related data structures are defined in gelic_udbg.
These could be easily dropped and the standard ones defined in network
headers could be used instead.

The 4 patches that follow replace ethernet, vlan, ip and udp
structures in gelic_udbg.  Note that this has been compile-tested
only.

Luis Henriques (4):
  powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
  powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>
  powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>
  powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>

 arch/powerpc/platforms/ps3/gelic_udbg.c | 71 +++++++++++----------------------
 1 file changed, 23 insertions(+), 48 deletions(-)

[toc] | [next] | [standalone]


#1328540 — [PATCH 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-07 18:40 +0100
Subject[PATCH 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>
Message-ID<qZBty-Xv-49@gated-at.bofh.it>
In reply to#1328538
Instead of defining a local version of struct udphdr use the standard
definition from <linux/udp.h>.

The 'src' field is named 'source' in the <linux/udp.h> definition.

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/platforms/ps3/gelic_udbg.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index 01d274fcbe51..b8f90a8465b9 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -16,6 +16,7 @@
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
 #include <linux/ip.h>
+#include <linux/udp.h>
 
 #include <asm/io.h>
 #include <asm/udbg.h>
@@ -60,13 +61,6 @@ struct debug_block {
 	u8 pkt[1520];
 } __packed;
 
-struct udphdr {
-	u16 src;
-	u16 dest;
-	u16 len;
-	u16 checksum;
-} __packed;
-
 static __iomem struct ethhdr *h_eth;
 static __iomem struct vlan_hdr *h_vlan;
 static __iomem struct iphdr *h_ip;
@@ -185,7 +179,7 @@ static void gelic_debug_init(void)
 
 	header_size += sizeof(struct udphdr);
 	h_udp = (struct udphdr *)(h_ip + 1);
-	h_udp->src = GELIC_DEBUG_PORT;
+	h_udp->source = GELIC_DEBUG_PORT;
 	h_udp->dest = GELIC_DEBUG_PORT;
 
 	pmsgc = pmsg = (char *)(h_udp + 1);

[toc] | [prev] | [next] | [standalone]


#1328542 — [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-07 18:50 +0100
Subject[PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
Message-ID<qZBDd-130-25@gated-at.bofh.it>
In reply to#1328538
Instead of defining a local version of struct ethhdr use the standard
definition from <linux/if_ether.h>.

The fields in the <linux/if_ether.h> definition have different names:
 - dest -> h_dest
 - src -> h_source
 - type -> h_proto

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/platforms/ps3/gelic_udbg.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index 20b46a19a48f..ac87811e8b4e 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -13,6 +13,8 @@
  *
  */
 
+#include <linux/if_ether.h>
+
 #include <asm/io.h>
 #include <asm/udbg.h>
 #include <asm/lv1call.h>
@@ -56,12 +58,6 @@ struct debug_block {
 	u8 pkt[1520];
 } __packed;
 
-struct ethhdr {
-	u8 dest[6];
-	u8 src[6];
-	u16 type;
-} __packed;
-
 struct vlantag {
 	u16 vlan;
 	u16 subtype;
@@ -173,8 +169,8 @@ static void gelic_debug_init(void)
 
 	h_eth = (struct ethhdr *)dbg.pkt;
 
-	memset(&h_eth->dest, 0xff, 6);
-	memcpy(&h_eth->src, &mac, 6);
+	memset(&h_eth->h_dest, 0xff, 6);
+	memcpy(&h_eth->h_source, &mac, 6);
 
 	header_size = sizeof(struct ethhdr);
 
@@ -183,7 +179,7 @@ static void gelic_debug_init(void)
 				 GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0,
 				 &vlan_id, &v2);
 	if (!result) {
-		h_eth->type = 0x8100;
+		h_eth->h_proto= 0x8100;
 
 		header_size += sizeof(struct vlantag);
 		h_vlan = (struct vlantag *)(h_eth + 1);
@@ -191,7 +187,7 @@ static void gelic_debug_init(void)
 		h_vlan->subtype = 0x0800;
 		h_ip = (struct iphdr *)(h_vlan + 1);
 	} else {
-		h_eth->type = 0x0800;
+		h_eth->h_proto= 0x0800;
 		h_ip = (struct iphdr *)(h_eth + 1);
 	}
 

[toc] | [prev] | [next] | [standalone]


#1328569 — Re: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>

FromJoe Perches <joe@perches.com>
Date2016-02-07 20:40 +0100
SubjectRe: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
Message-ID<qZDlF-2oc-21@gated-at.bofh.it>
In reply to#1328542
On Sun, 2016-02-07 at 17:38 +0000, Luis Henriques wrote:
> Instead of defining a local version of struct ethhdr use the standard
> definition from .

trivia:

> diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
[]
> @@ -173,8 +169,8 @@ static void gelic_debug_init(void)
>  
>  	h_eth = (struct ethhdr *)dbg.pkt;
>  
> -	memset(&h_eth->dest, 0xff, 6);
> -	memcpy(&h_eth->src, &mac, 6);
> +	memset(&h_eth->h_dest, 0xff, 6);
> +	memcpy(&h_eth->h_source, &mac, 6);

Be nice to use ETH_ALEN and eth_broadcast_addr.
Maybe ether_addr_copy too.

> @@ -183,7 +179,7 @@ static void gelic_debug_init(void)
>  				 GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0,
>  				 &vlan_id, &v2);
>  	if (!result) {
> -		h_eth->type = 0x8100;
> +		h_eth->h_proto= 0x8100;

ETH_P_8021Q

>  		header_size += sizeof(struct vlantag);
>  		h_vlan = (struct vlantag *)(h_eth + 1);
> @@ -191,7 +187,7 @@ static void gelic_debug_init(void)
>  		h_vlan->subtype = 0x0800;
>  		h_ip = (struct iphdr *)(h_vlan + 1);
>  	} else {
> -		h_eth->type = 0x0800;
> +		h_eth->h_proto= 0x0800;

ETH_P_IP

[toc] | [prev] | [next] | [standalone]


#1329616 — Re: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-08 23:10 +0100
SubjectRe: [PATCH 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
Message-ID<r02am-2VY-5@gated-at.bofh.it>
In reply to#1328569
Hi,

On Sun, Feb 07, 2016 at 10:26:51AM -0800, Joe Perches wrote:
> On Sun, 2016-02-07 at 17:38 +0000, Luis Henriques wrote:
> > Instead of defining a local version of struct ethhdr use the standard
> > definition from .
> 
> trivia:
> 
> > diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
> []
> > @@ -173,8 +169,8 @@ static void gelic_debug_init(void)
> >  
> >  	h_eth = (struct ethhdr *)dbg.pkt;
> >  
> > -	memset(&h_eth->dest, 0xff, 6);
> > -	memcpy(&h_eth->src, &mac, 6);
> > +	memset(&h_eth->h_dest, 0xff, 6);
> > +	memcpy(&h_eth->h_source, &mac, 6);
> 
> Be nice to use ETH_ALEN and eth_broadcast_addr.
> Maybe ether_addr_copy too.
> 
> > @@ -183,7 +179,7 @@ static void gelic_debug_init(void)
> >  				 GELIC_LV1_VLAN_TX_ETHERNET_0, 0, 0,
> >  				 &vlan_id, &v2);
> >  	if (!result) {
> > -		h_eth->type = 0x8100;
> > +		h_eth->h_proto= 0x8100;
> 
> ETH_P_8021Q
> 
> >  		header_size += sizeof(struct vlantag);
> >  		h_vlan = (struct vlantag *)(h_eth + 1);
> > @@ -191,7 +187,7 @@ static void gelic_debug_init(void)
> >  		h_vlan->subtype = 0x0800;
> >  		h_ip = (struct iphdr *)(h_vlan + 1);
> >  	} else {
> > -		h_eth->type = 0x0800;
> > +		h_eth->h_proto= 0x0800;
> 
> ETH_P_IP

Great, I'll send out v2 that will include most of these comments.  The
one I'll leave out is the usage of ether_addr_copy.

Thanks a lot for your comments.

Cheers,
--
Luís

[toc] | [prev] | [next] | [standalone]


#1328544 — [PATCH 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-07 18:50 +0100
Subject[PATCH 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>
Message-ID<qZBDd-130-29@gated-at.bofh.it>
In reply to#1328538
Instead of defining a local version of struct iphdr use the standard
definition from <linux/ip.h>.

Several fields in the <linux/ip.h> definition have different names:
 - proto -> protocol
 - src -> saddr
 - dest -> daddr
 - total_length -> tot_len
 - checksum -> check

Also, 'ver_len' is composed by 'version' and 'ihl' in <linux/ip.h>.

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/platforms/ps3/gelic_udbg.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index 4d6e827edfde..01d274fcbe51 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -15,6 +15,7 @@
 
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
+#include <linux/ip.h>
 
 #include <asm/io.h>
 #include <asm/udbg.h>
@@ -59,19 +60,6 @@ struct debug_block {
 	u8 pkt[1520];
 } __packed;
 
-struct iphdr {
-	u8 ver_len;
-	u8 dscp_ecn;
-	u16 total_length;
-	u16 ident;
-	u16 frag_off_flags;
-	u8 ttl;
-	u8 proto;
-	u16 checksum;
-	u32 src;
-	u32 dest;
-} __packed;
-
 struct udphdr {
 	u16 src;
 	u16 dest;
@@ -188,11 +176,12 @@ static void gelic_debug_init(void)
 	}
 
 	header_size += sizeof(struct iphdr);
-	h_ip->ver_len = 0x45;
+	h_ip->version = 4;
+	h_ip->ihl = 5;
 	h_ip->ttl = 10;
-	h_ip->proto = 0x11;
-	h_ip->src = 0x00000000;
-	h_ip->dest = 0xffffffff;
+	h_ip->protocol = 0x11;
+	h_ip->saddr = 0x00000000;
+	h_ip->daddr = 0xffffffff;
 
 	header_size += sizeof(struct udphdr);
 	h_udp = (struct udphdr *)(h_ip + 1);
@@ -217,16 +206,16 @@ static void gelic_sendbuf(int msgsize)
 	int i;
 
 	dbg.descr.buf_size = header_size + msgsize;
-	h_ip->total_length = msgsize + sizeof(struct udphdr) +
+	h_ip->tot_len = msgsize + sizeof(struct udphdr) +
 			     sizeof(struct iphdr);
 	h_udp->len = msgsize + sizeof(struct udphdr);
 
-	h_ip->checksum = 0;
+	h_ip->check = 0;
 	sum = 0;
 	p = (u16 *)h_ip;
 	for (i = 0; i < 5; i++)
 		sum += *p++;
-	h_ip->checksum = ~(sum + (sum >> 16));
+	h_ip->check = ~(sum + (sum >> 16));
 
 	dbg.descr.dmac_cmd_status = GELIC_DESCR_DMA_CMD_NO_CHKSUM |
 				    GELIC_DESCR_TX_DMA_FRAME_TAIL;

[toc] | [prev] | [next] | [standalone]


#1328547 — [PATCH 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-07 18:50 +0100
Subject[PATCH 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>
Message-ID<qZBDd-130-43@gated-at.bofh.it>
In reply to#1328538
Instead of defining the local struct vlantag use the standard definition
of vlan_hdr from <linux/if_vlan.h>.

The fields in the <linux/if_vlan.h> definition have different names:
 - vlan -> h_vlan_TCI
 - subtype -> h_vlan_encapsulated_proto

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/powerpc/platforms/ps3/gelic_udbg.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index ac87811e8b4e..4d6e827edfde 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -14,6 +14,7 @@
  */
 
 #include <linux/if_ether.h>
+#include <linux/if_vlan.h>
 
 #include <asm/io.h>
 #include <asm/udbg.h>
@@ -58,11 +59,6 @@ struct debug_block {
 	u8 pkt[1520];
 } __packed;
 
-struct vlantag {
-	u16 vlan;
-	u16 subtype;
-} __packed;
-
 struct iphdr {
 	u8 ver_len;
 	u8 dscp_ecn;
@@ -84,7 +80,7 @@ struct udphdr {
 } __packed;
 
 static __iomem struct ethhdr *h_eth;
-static __iomem struct vlantag *h_vlan;
+static __iomem struct vlan_hdr *h_vlan;
 static __iomem struct iphdr *h_ip;
 static __iomem struct udphdr *h_udp;
 
@@ -181,10 +177,10 @@ static void gelic_debug_init(void)
 	if (!result) {
 		h_eth->h_proto= 0x8100;
 
-		header_size += sizeof(struct vlantag);
-		h_vlan = (struct vlantag *)(h_eth + 1);
-		h_vlan->vlan = vlan_id;
-		h_vlan->subtype = 0x0800;
+		header_size += sizeof(struct vlan_hdr);
+		h_vlan = (struct vlan_hdr *)(h_eth + 1);
+		h_vlan->h_vlan_TCI = vlan_id;
+		h_vlan->h_vlan_encapsulated_proto = 0x0800;
 		h_ip = (struct iphdr *)(h_vlan + 1);
 	} else {
 		h_eth->h_proto= 0x0800;

[toc] | [prev] | [next] | [standalone]


#1328819 — Re: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-02-08 09:40 +0100
SubjectRe: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
Message-ID<qZPwu-2Hf-3@gated-at.bofh.it>
In reply to#1328538
On Sun, Feb 7, 2016 at 6:38 PM, Luis Henriques
<luis.henriques@canonical.com> wrote:
> Several network-related data structures are defined in gelic_udbg.
> These could be easily dropped and the standard ones defined in network
> headers could be used instead.
>
> The 4 patches that follow replace ethernet, vlan, ip and udp
> structures in gelic_udbg.  Note that this has been compile-tested
> only.

A few of these were declared __packed in the gelic driver, while that
attribute isn't used for the standard definitions.

It probably doesn't make a difference, as there are no gaps in the structures
when unpacked, unless pointers to the structures themselves are unaligned.

> Luis Henriques (4):
>   powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
>   powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>
>   powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>
>   powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>
>
>  arch/powerpc/platforms/ps3/gelic_udbg.c | 71 +++++++++++----------------------
>  1 file changed, 23 insertions(+), 48 deletions(-)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [prev] | [next] | [standalone]


#1329634 — Re: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs

FromLuis Henriques <luis.henriques@canonical.com>
Date2016-02-08 23:20 +0100
SubjectRe: [PATCH 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
Message-ID<r02k2-2Zq-27@gated-at.bofh.it>
In reply to#1328819
On Mon, Feb 08, 2016 at 09:31:21AM +0100, Geert Uytterhoeven wrote:
> On Sun, Feb 7, 2016 at 6:38 PM, Luis Henriques
> <luis.henriques@canonical.com> wrote:
> > Several network-related data structures are defined in gelic_udbg.
> > These could be easily dropped and the standard ones defined in network
> > headers could be used instead.
> >
> > The 4 patches that follow replace ethernet, vlan, ip and udp
> > structures in gelic_udbg.  Note that this has been compile-tested
> > only.
> 
> A few of these were declared __packed in the gelic driver, while that
> attribute isn't used for the standard definitions.
> 
> It probably doesn't make a difference, as there are no gaps in the structures
> when unpacked, unless pointers to the structures themselves are unaligned.
>

Thank you for your comments, Geert.  I had noticed those differences,
but the quick code review I did didn't show any issues with that could
be triggered by this change.  But as I referred, I only compile-tested
this code and didn't actually executed it in the real hw.

Cheers,
--
Luís

> > Luis Henriques (4):
> >   powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
> >   powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>
> >   powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>
> >   powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>
> >
> >  arch/powerpc/platforms/ps3/gelic_udbg.c | 71 +++++++++++----------------------
> >  1 file changed, 23 insertions(+), 48 deletions(-)
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web