* [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
@ 2016-02-08 22:27 Luis Henriques
2016-02-08 22:27 ` [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Luis Henriques @ 2016-02-08 22:27 UTC (permalink / raw)
To: Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
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.
Changes since v1:
Include changes suggested by Joe Perches, namely the usage of
eth_broadcast_addr(), ETH_ALEN, ETH_P_8021Q and ETH_P_IP.
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 | 72 +++++++++++----------------------
1 file changed, 24 insertions(+), 48 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
@ 2016-02-08 22:27 ` Luis Henriques
2016-03-01 22:21 ` [v2, " Michael Ellerman
2016-02-08 22:27 ` [PATCH v2 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h> Luis Henriques
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Luis Henriques @ 2016-02-08 22:27 UTC (permalink / raw)
To: Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
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
While there, use a few other standard functions/macros:
- eth_broadcast_addr (instead of a memset)
- ETH_ALEN
- ETH_P_8021Q
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
arch/powerpc/platforms/ps3/gelic_udbg.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/platforms/ps3/gelic_udbg.c b/arch/powerpc/platforms/ps3/gelic_udbg.c
index 20b46a19a48f..f11059e1ec35 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -13,6 +13,9 @@
*
*/
+#include <linux/if_ether.h>
+#include <linux/etherdevice.h>
+
#include <asm/io.h>
#include <asm/udbg.h>
#include <asm/lv1call.h>
@@ -56,12 +59,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 +170,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);
+ eth_broadcast_addr(h_eth->h_dest);
+ memcpy(&h_eth->h_source, &mac, ETH_ALEN);
header_size = sizeof(struct ethhdr);
@@ -183,7 +180,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= ETH_P_8021Q;
header_size += sizeof(struct vlantag);
h_vlan = (struct vlantag *)(h_eth + 1);
@@ -191,7 +188,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);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h>
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
2016-02-08 22:27 ` [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques
@ 2016-02-08 22:27 ` Luis Henriques
2016-02-08 22:27 ` [PATCH v2 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h> Luis Henriques
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Luis Henriques @ 2016-02-08 22:27 UTC (permalink / raw)
To: Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
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
While there, use also the ETH_P_IP macro instead of an hard-coded 0x0800
value.
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 f11059e1ec35..bbf9c9904caf 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/etherdevice.h>
+#include <linux/if_vlan.h>
#include <asm/io.h>
#include <asm/udbg.h>
@@ -59,11 +60,6 @@ struct debug_block {
u8 pkt[1520];
} __packed;
-struct vlantag {
- u16 vlan;
- u16 subtype;
-} __packed;
-
struct iphdr {
u8 ver_len;
u8 dscp_ecn;
@@ -85,7 +81,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;
@@ -182,10 +178,10 @@ static void gelic_debug_init(void)
if (!result) {
h_eth->h_proto= ETH_P_8021Q;
- 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 = ETH_P_IP;
h_ip = (struct iphdr *)(h_vlan + 1);
} else {
h_eth->h_proto= 0x0800;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h>
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
2016-02-08 22:27 ` [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques
2016-02-08 22:27 ` [PATCH v2 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h> Luis Henriques
@ 2016-02-08 22:27 ` Luis Henriques
2016-02-08 22:27 ` [PATCH v2 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h> Luis Henriques
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Luis Henriques @ 2016-02-08 22:27 UTC (permalink / raw)
To: Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
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 bbf9c9904caf..d69f33dcc64b 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/etherdevice.h>
#include <linux/if_vlan.h>
+#include <linux/ip.h>
#include <asm/io.h>
#include <asm/udbg.h>
@@ -60,19 +61,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;
@@ -189,11 +177,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);
@@ -218,16 +207,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;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h>
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
` (2 preceding siblings ...)
2016-02-08 22:27 ` [PATCH v2 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h> Luis Henriques
@ 2016-02-08 22:27 ` Luis Henriques
2016-02-09 2:54 ` Michael Ellerman
2016-02-11 23:20 ` Geoff Levand
5 siblings, 0 replies; 9+ messages in thread
From: Luis Henriques @ 2016-02-08 22:27 UTC (permalink / raw)
To: Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
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 d69f33dcc64b..09bf24d616a5 100644
--- a/arch/powerpc/platforms/ps3/gelic_udbg.c
+++ b/arch/powerpc/platforms/ps3/gelic_udbg.c
@@ -17,6 +17,7 @@
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
+#include <linux/udp.h>
#include <asm/io.h>
#include <asm/udbg.h>
@@ -61,13 +62,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;
@@ -186,7 +180,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);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
@ 2016-02-09 2:54 ` Michael Ellerman
2016-02-08 22:27 ` [PATCH v2 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h> Luis Henriques
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Michael Ellerman @ 2016-02-09 2:54 UTC (permalink / raw)
To: Luis Henriques, Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
On Mon, 2016-02-08 at 22:27 +0000, Luis Henriques 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.
>
> Changes since v1:
> Include changes suggested by Joe Perches, namely the usage of
> eth_broadcast_addr(), ETH_ALEN, ETH_P_8021Q and ETH_P_IP.
>
> 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>
These look good. But I don't have a setup to test them, does anyone?
I'll merge them and hopefully someone can test them at some point.
cheers
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
@ 2016-02-09 2:54 ` Michael Ellerman
0 siblings, 0 replies; 9+ messages in thread
From: Michael Ellerman @ 2016-02-09 2:54 UTC (permalink / raw)
To: Luis Henriques, Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel
On Mon, 2016-02-08 at 22:27 +0000, Luis Henriques 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.
>
> Changes since v1:
> Include changes suggested by Joe Perches, namely the usage of
> eth_broadcast_addr(), ETH_ALEN, ETH_P_8021Q and ETH_P_IP.
>
> 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>
These look good. But I don't have a setup to test them, does anyone?
I'll merge them and hopefully someone can test them at some point.
cheers
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
` (4 preceding siblings ...)
2016-02-09 2:54 ` Michael Ellerman
@ 2016-02-11 23:20 ` Geoff Levand
5 siblings, 0 replies; 9+ messages in thread
From: Geoff Levand @ 2016-02-11 23:20 UTC (permalink / raw)
To: Luis Henriques, Michael Ellerman
Cc: Joe Perches, Geert Uytterhoeven, linuxppc-dev, linux-kernel,
Benjamin Herrenschmidt, Paul Mackerras
[-- Attachment #1: Type: text/html, Size: 6459 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [v2, 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h>
2016-02-08 22:27 ` [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques
@ 2016-03-01 22:21 ` Michael Ellerman
0 siblings, 0 replies; 9+ messages in thread
From: Michael Ellerman @ 2016-03-01 22:21 UTC (permalink / raw)
To: Luis Henriques, Geoff Levand, Benjamin Herrenschmidt, Paul Mackerras
Cc: Joe Perches, linuxppc-dev, Geert Uytterhoeven, linux-kernel
On Mon, 2016-08-02 at 22:27:04 UTC, Luis Henriques wrote:
> 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
>
> While there, use a few other standard functions/macros:
> - eth_broadcast_addr (instead of a memset)
> - ETH_ALEN
> - ETH_P_8021Q
>
> Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/497abcf6afe2d85f047fbf1373
cheers
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-03-01 22:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 22:27 [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Luis Henriques
2016-02-08 22:27 ` [PATCH v2 1/4] powerpc/ps3: gelic_udbg: use struct ethhdr from <linux/if_ether.h> Luis Henriques
2016-03-01 22:21 ` [v2, " Michael Ellerman
2016-02-08 22:27 ` [PATCH v2 2/4] powerpc/ps3: gelic_udbg: use struct vlan_hdr from <linux/if_vlan.h> Luis Henriques
2016-02-08 22:27 ` [PATCH v2 3/4] powerpc/ps3: gelic_udbg: use struct iphdr from <linux/ip.h> Luis Henriques
2016-02-08 22:27 ` [PATCH v2 4/4] powerpc/ps3: gelic_udbg: use struct udphdr from <linux/udp.h> Luis Henriques
2016-02-09 2:54 ` [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs Michael Ellerman
2016-02-09 2:54 ` Michael Ellerman
2016-02-11 23:20 ` Geoff Levand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.