Skip to content

Commit

Permalink
net: prp: add packet handling support
Browse files Browse the repository at this point in the history
DAN-P (Dual Attached Nodes PRP) nodes are expected to receive
traditional IP packets as well as PRP (Parallel Redundancy
Protocol) tagged (trailer) packets. PRP trailer is 6 bytes
of PRP protocol unit called RCT, Redundancy Control Trailer
(RCT) similar to HSR tag. PRP network can have traditional
devices such as bridges/switches or PC attached to it and
should be able to communicate. Regular Ethernet devices treat
the RCT as pads.  This patch adds logic to format L2 frames
from network stack to add a trailer (RCT) and send it as
duplicates over the slave interfaces when the protocol is
PRP as per IEC 62439-3. At the ingress, it strips the trailer,
do duplicate detection and rejection and forward a stripped
frame up the network stack. PRP device should accept frames
from Singly Attached Nodes (SAN) and thus the driver mark
the link where the frame came from in the node table.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Murali Karicheri authored and davem330 committed Jul 27, 2020
1 parent fa4dc89 commit 451d812
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 88 deletions.
20 changes: 14 additions & 6 deletions net/hsr/hsr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,17 @@ static struct hsr_proto_ops hsr_ops = {
.create_tagged_frame = hsr_create_tagged_frame,
.get_untagged_frame = hsr_get_untagged_frame,
.fill_frame_info = hsr_fill_frame_info,
.invalid_dan_ingress_frame = hsr_invalid_dan_ingress_frame,
};

static struct hsr_proto_ops prp_ops = {
.send_sv_frame = send_prp_supervision_frame,
.create_tagged_frame = prp_create_tagged_frame,
.get_untagged_frame = prp_get_untagged_frame,
.drop_frame = prp_drop_frame,
.fill_frame_info = prp_fill_frame_info,
.handle_san_frame = prp_handle_san_frame,
.update_san_info = prp_update_san_info,
};

void hsr_dev_setup(struct net_device *dev)
Expand Down Expand Up @@ -508,15 +515,16 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],

ether_addr_copy(hsr_dev->dev_addr, slave[0]->dev_addr);

/* currently PRP is not supported */
if (protocol_version == PRP_V1)
return -EPROTONOSUPPORT;

/* initialize protocol specific functions */
if (protocol_version == PRP_V1)
if (protocol_version == PRP_V1) {
/* For PRP, lan_id has most significant 3 bits holding
* the net_id of PRP_LAN_ID
*/
hsr->net_id = PRP_LAN_ID << 1;
hsr->proto_ops = &prp_ops;
else
} else {
hsr->proto_ops = &hsr_ops;
}

/* Make sure we recognize frames from ourselves in hsr_rcv() */
res = hsr_create_self_node(hsr, hsr_dev->dev_addr,
Expand Down

0 comments on commit 451d812

Please sign in to comment.