<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p
{mso-style-priority:99;
margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-style-priority:99;
margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Indeed, I’m using RT_PREEMPT.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">After some trial and error I was able to get EoE working while the master is in OP mode.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Eventually I didn’t drive the EoE fsm from RT interrupt context but from EtherCAT-OP thread.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’m not sure about the implications of this design.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Should I be aware of something with regard to this choice?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Any comments are appreciated.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’m not sure if it’s the right way to do it, but EoE seems to be working properly. I’m currently stress testing the system.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">My patch is added for your evaluation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks a lot,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Nir.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">diff -ur etherlab_patchset_20160804/master/ethernet.c etherlab_eoe_op/master/ethernet.c<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--- etherlab_patchset_20160804/master/ethernet.c 2017-01-23 17:00:50.657116495 +0200<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+++ etherlab_eoe_op/master/ethernet.c 2017-01-23 17:47:04.728268793 +0200<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -442,10 +442,18 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">void ec_eoe_queue(ec_eoe_t *eoe /**< EoE handler */)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- if (eoe->queue_datagram) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- ec_master_queue_datagram_ext(eoe->slave->master, &eoe->datagram);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- eoe->queue_datagram = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (eoe->queue_datagram) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if(EC_OPERATION == eoe->slave->master->phase)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_master_queue_datagram(eoe->slave->master, &eoe->datagram);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ else<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_master_queue_datagram_ext(eoe->slave->master, &eoe->datagram);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ eoe->queue_datagram = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> /*****************************************************************************/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -580,6 +588,7 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> size_t rec_size, data_size;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> uint8_t *data, frame_type, last_fragment, time_appended, mbox_prot;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> uint8_t fragment_offset, fragment_number;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ unsigned int skb_alloc_size = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#if EOE_DEBUG_LEVEL >= 2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> uint8_t frame_number;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#endif<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -647,8 +656,8 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#endif<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> #if EOE_DEBUG_LEVEL >= 2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- EC_SLAVE_DBG(eoe->slave, 0, "EoE %s RX fragment %u%s, offset %u,"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- " frame %u%s, %zu octets\n", eoe->dev->name, fragment_number,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ EC_SLAVE_DBG(eoe->slave, 0, "EoE %s RX fragment %u%s, fragment_offset %u,"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ " frame_number %u%s, %zu octets\n", eoe->dev->name, fragment_number,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> last_fragment ? "" : "+", fragment_offset, frame_number,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> time_appended ? ", + timestamp" : "",<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> time_appended ? rec_size - 8 : rec_size - 4);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -675,7 +684,18 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> // new socket buffer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- if (!(eoe->rx_skb = dev_alloc_skb(fragment_offset * 32))) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if(fragment_offset)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ skb_alloc_size = fragment_offset * 32;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ else<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ EC_SLAVE_DBG(eoe->slave, 0, "ec_eoe_state_rx_fetch: fragment_offset=0 !!!! allocating skb size 1500!!!!\n");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ skb_alloc_size = 1500;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (!(eoe->rx_skb = dev_alloc_skb(skb_alloc_size))) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> if (printk_ratelimit())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> EC_SLAVE_WARN(eoe->slave, "EoE RX low on mem,"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> " frame dropped.\n");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -685,9 +705,10 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->rx_skb_offset = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- eoe->rx_skb_size = fragment_offset * 32;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ eoe->rx_skb_size = skb_alloc_size;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->rx_expected_fragment = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ /* if this is NOT the first fragment */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> else {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> if (!eoe->rx_skb) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->stats.rx_dropped++;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -696,8 +717,11 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> offset = fragment_offset * 32;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- if (offset != eoe->rx_skb_offset ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- offset + data_size > eoe->rx_skb_size ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ // motivation for offset != eoe->rx_skb_offset is unclear, because offset is rounded to 32 bits chuncks<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ // and eoe->rx_skb_offset is byte accurate<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ /*if (offset != eoe->rx_skb_offset ||
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ offset + data_size > eoe->rx_skb_size ||*/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if(offset + data_size > eoe->rx_skb_size ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> fragment_number != eoe->rx_expected_fragment) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> dev_kfree_skb(eoe->rx_skb);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->rx_skb = NULL;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -838,6 +862,9 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->tries--; // try again<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->queue_datagram = 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> } else {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ dev_kfree_skb(eoe->tx_frame->skb);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ kfree(eoe->tx_frame);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ eoe->tx_frame = NULL;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->stats.tx_errors++;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#if EOE_DEBUG_LEVEL >= 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> EC_SLAVE_WARN(eoe->slave, "Failed to receive send"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -854,6 +881,9 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->tries--; // try again<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->queue_datagram = 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> } else {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ dev_kfree_skb(eoe->tx_frame->skb);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ kfree(eoe->tx_frame);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ eoe->tx_frame = NULL;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> eoe->stats.tx_errors++;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#if EOE_DEBUG_LEVEL >= 1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> EC_SLAVE_WARN(eoe->slave, "No sending response"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">diff -ur etherlab_patchset_20160804/master/master.c etherlab_eoe_op/master/master.c<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--- etherlab_patchset_20160804/master/master.c 2017-01-23 17:00:41.873182432 +0200<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+++ etherlab_eoe_op/master/master.c 2017-01-23 17:51:39.978196560 +0200<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -106,6 +106,8 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">void ec_master_clear_device_stats(ec_master_t *);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">void ec_master_update_device_stats(ec_master_t *);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+void ecatmc_eoe_fsm(void* priv_data);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">/*****************************************************************************/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> /** Static variables initializer.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -1816,6 +1818,9 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> ec_master_exec_slave_fsms(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ /* Drive the EoE state machine */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ecatmc_eoe_fsm((void*)master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> ec_lock_up(&master->master_sem);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -1958,6 +1963,48 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> /*****************************************************************************/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+void ecatmc_eoe_fsm(void* priv_data)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_master_t *master = (ec_master_t *) priv_data;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_eoe_t *eoe;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ unsigned int none_open, sth_to_send, all_idle;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ none_open = 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ list_for_each_entry(eoe, &master->eoe_handlers, list) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (ec_eoe_is_open(eoe)) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ none_open = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ break;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (none_open)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ return;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ // actual EoE processing<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ sth_to_send = 0;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ list_for_each_entry(eoe, &master->eoe_handlers, list) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if ((eoe->slave->current_state == EC_SLAVE_STATE_PREOP) ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ (eoe->slave->current_state == EC_SLAVE_STATE_SAFEOP) ||<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ (eoe->slave->current_state == EC_SLAVE_STATE_OP)) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_eoe_run(eoe);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (eoe->queue_datagram) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ sth_to_send = 1;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (!ec_eoe_is_idle(eoe)) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ all_idle = 0;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ if (sth_to_send) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ list_for_each_entry(eoe, &master->eoe_handlers, list) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_eoe_queue(eoe);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ }
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+/*****************************************************************************/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">/** Attaches the slave configurations to the slaves.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">void ec_master_attach_slave_configs(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -2614,11 +2661,6 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> master->receive_cb = master->app_receive_cb;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> master->cb_data = master->app_cb_data;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-#ifdef EC_EOE<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- if (eoe_was_running) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- ec_master_eoe_start(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-#endif<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> ret = ec_master_thread_start(master, ec_master_operation_thread,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> "EtherCAT-OP");<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> if (ret < 0) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -2705,10 +2747,6 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> ec_master_thread_stop(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-#ifdef EC_EOE<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- eoe_was_running = master->eoe_thread != NULL;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- ec_master_eoe_stop(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-#endif<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> master->send_cb = ec_master_internal_send_cb;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> master->receive_cb = ec_master_internal_receive_cb;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">@@ -2749,9 +2787,7 @@<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> master->active = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> #ifdef EC_EOE<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- if (eoe_was_running) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- ec_master_eoe_start(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">- }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">+ ec_master_eoe_start(master);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#endif<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> if (ec_master_thread_start(master, ec_master_idle_thread,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> "EtherCAT-IDLE")) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Gavin Lambert [<a href="mailto:gavinl@compacsort.com">mailto:gavinl@compacsort.com</a>]
<br>
<b>Sent:</b> Thursday, January 19, 2017 1:32 AM<br>
<b>To:</b> Geller, Nir; <a href="mailto:etherlab-dev@etherlab.org">etherlab-dev@etherlab.org</a>; Slutsker, Rasty<br>
<b>Subject:</b> RE: EoE in OP mode<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Note that the patchset has only really been tested with RT_PREEMPT or otherwise standard user mode usage.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">In particular, there are some patches that change locks and callbacks in ways that I don’t think are entirely compatible with RTAI / Xenomai; there have previously
been reported problems using those with this patchset.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">As I was neither the author of those patches nor do I use Xenomai (or EoE) myself, I don’t really know what needs to be done to resolve the issues (except just
dropping them and possibly breaking the scenario they were originally authored to fix); additionally, I don’t have much time at the moment to work on EtherCAT. I welcome assistance in correcting this situation.
</span><span lang="EN-NZ" style="font-size:11.0pt;font-family:Wingdings">J</span><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">As far as I understand, ec_master_send/receive are only ever supposed to be invoked on one thread at a time; when you’re using the userspace library this is
enforced by a Linux lock in the corresponding ioctl, but this doesn’t apply or is insufficient when using a kernel-mode application or RTAI/Xenomai. In those, you need to register callbacks and use your own appropriate locking mechanism to ensure that the
send/receive are not called concurrently.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">In particular note that both the send callback and the receive callback are permitted to do nothing if called in a context where they can’t wait on a lock but
something else is concurrently busy doing the same thing. So if you’re calling send/receive from an interrupt thread, you will need to keep track of this and force the EoE thread callback to block until the interrupt is done,
<b>and also</b> to make the interrupt thread avoid send/receive without blocking if the EoE thread is already in the middle of it. Alternately you could probably make the interrupt handler responsible to do both of these things and have the EoE callbacks always
do nothing, which might be better for your application performance. (Though like I said, I haven’t looked at the code much in this area so take these suggestions with a grain of salt; I could have something incorrect.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-NZ" style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> etherlab-dev [</span><a href="mailto:etherlab-dev-bounces@etherlab.org"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">mailto:etherlab-dev-bounces@etherlab.org</span></a><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">]
<b>On Behalf Of </b>Geller, Nir<br>
<b>Sent:</b> Wednesday, 18 January 2017 23:38<br>
<b>To:</b> </span><a href="mailto:etherlab-dev@etherlab.org"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">etherlab-dev@etherlab.org</span></a><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">; Slutsker, Rasty <</span><a href="mailto:rasty.slutsker@servotronix.com"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">rasty.slutsker@servotronix.com</span></a><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">><br>
<b>Subject:</b> [etherlab-dev] EoE in OP mode<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-NZ"><o:p> </o:p></span></p>
<div id="divtagdefaultwrapper">
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Hi,<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">I recently upgraded ethercat master to Gavin Patchset 20160804, adding to that, patch 0061.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">EoE seems to be working fine while the master is idle, with heavy SDO traffic in parallel.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">When the master is active our realtime application invokes ecrt_master_receive(master); and ecrt_master_send(master); from interrupt context, and NOT from <o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">ec_master_operation_thread() thread context.<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">The problem comes up when the master is active.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Just as I issue<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">ifconfig eoe0a1 up<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">I get a bunch of UNMATCHED DATAGRAMS in the kernel log, and the master is released.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324525] EtherCAT DEBUG 0: UNMATCHED datagram:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324528] EtherCAT DEBUG: 0D 83 01 00 10 09 08 80 00 00 68 5A 4A 84 9C 9B <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324539] EtherCAT DEBUG: 84 11 01 00 <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324544] EtherCAT DEBUG 0: UNMATCHED datagram:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324547] EtherCAT DEBUG: 04 84 01 00 90 09 08 80 00 00 B0 3D 4C 84 9C 9B <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324557] EtherCAT DEBUG: 84 11 01 00 <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324562] EtherCAT DEBUG 0: UNMATCHED datagram:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324565] EtherCAT DEBUG: 0C 85 00 00 00 00 10 80 00 00 00 00 70 FF FF FF <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324575] EtherCAT DEBUG: 50 52 70 FF FF FF 00 00 31 00 03 00 <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324584] EtherCAT DEBUG 0: UNMATCHED datagram:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324587] EtherCAT DEBUG: 07 86 01 00 30 01 02 00 00 00 08 00 01 00 <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324838] EtherCAT 0: fsm->slaves_responding[fsm->dev_idx]=1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324843] EtherCAT 0: 0 slave(s) responding on main device.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324846] EtherCAT 0: datagram->working_counter=0 <------------------------- In wireshark capture WC is 1 !!!!<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324850] EtherCAT 0: datagram->state=4<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324853] EtherCAT 0: datagram->device_index=0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324856] EtherCAT 0: datagram->device_origin=0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324860] EtherCAT 0: datagram->index=134<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324863] EtherCAT 0: datagram->type=7<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 73.324866] EtherCAT DEBUG 0: Rescanning the bus<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">This happens due to a timeout. When the EoE thread invokes<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">master->receive_cb(master->cb_data); which leads to invoke of ecrt_master_receive(master); it somehow messes up <o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">master->devices[EC_DEVICE_MAIN].cycles_poll<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">which leads to a negative time delta in the calculation master->devices[EC_DEVICE_MAIN].cycles_poll - datagram->cycles_sent.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Attempting to bypass that in the EoE thread, I commented out master->receive_cb(master->cb_data); and master->send_cb(master->cb_data);<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">and once I invoke<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">ifconfig eoe0a1 up<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">I get an explosion of<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 123.529911] EtherCAT WARNING 0-main-0: Failed to receive mbox check datagram for eoe0a1.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 123.529918] EtherCAT WARNING 0-main-0: Failed to receive mbox check datagram for eoe0a1.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 123.529925] EtherCAT WARNING 0-main-0: Failed to receive mbox check datagram for eoe0a1.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">[ 123.529932] EtherCAT WARNING 0-main-0: Failed to receive mbox check datagram for eoe0a1.<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">If I comment out only master->receive_cb(master->cb_data);<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">I get no errors in dmesg, but then of course, EoE is not functional, and EoE thread starts gathering more and more CPU usage.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">I understand that an invoke of master->send_cb(master->cb_data); leads to <o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">ec_master_internal_send_cb --> ecrt_master_send_ext(master); <o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">which pulls datagrams from master->ext_datagram_queue and pushes them forward with ec_master_queue_datagram(), and then<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">invokes ecrt_master_send(master); which will lead to a collision with ecrt_master_send() in the interrupt context.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">So instead of invoking master->send_cb(master->cb_data); i tried only to pass datagrams from master->ext_datagram_queue,<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">but it caused a kernel panic.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">So, if I want EoE to work when the master is active, how should I pass datagrams from EoE thread to the master?<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Should I change the ethernet.c state machine?<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Thanks a lot,<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black">Nir.<o:p></o:p></span></p>
<p><span lang="EN-NZ" style="font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
</div>
</div>
</body>
</html>