Skip to content

Commit

Permalink
Mardkwon:Add utf-8 set and Debug wrong begin of title
Browse files Browse the repository at this point in the history
  • Loading branch information
sqm2050 committed Jun 8, 2013
1 parent 3baeee1 commit bf8b060
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 4 deletions.
2 changes: 1 addition & 1 deletion markdown/css.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
char *css = "<style id=\"system\" type=\"text/css\">*{margin:0;padding:0;} html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; background:#eeeeee;} body { font:15px helvetica,arial,freesans,clean,sans-serif; color:black; line-height:1.4em; background-color: #FFF; padding: 0.7em;} p { margin:1em 0; line-height:1.5em;} table { font-size:inherit; font:100%; margin:1em;} table th{border-bottom:1px solid #bbb;padding:.2em 1em;} table td{border-bottom:1px solid #ddd;padding:.2em 1em;} input[type=text],input[type=password],input[type=image],textarea{font:99\% helvetica,arial,freesans,sans-serif;} select,option{padding:0 .25em;} optgroup{margin-top:.5em;} pre,code{font:13px \"DejaVu Sans Mono\",\"Bitstream Vera Sans Mono\",monospace;} pre { margin:1em 0; font-size:13px; background-color:#eee; border:1px solid #ddd; padding:5px; line-height:1.5em; color:#444; overflow:auto; -webkit-box-shadow:rgba(0,0,0,0.07) 0 1px 2px inset; -webkit-border-radius:3px; -moz-border-radius:3px;border-radius:3px;} pre code { padding:0; font-size:13px; background-color:#eee; border:none;} code { font-size:13px; background-color:#eee; color:#d14; pading:2px 4px border:1px solid #elele8;border-radius:3px} img{border:0;max-width:100%;} abbr{border-bottom:none;} a{color:#4183c4;text-decoration:none;} a:hover{text-decoration:underline;} a code,a:link code,a:visited code{color:#4183c4;} h2,h3{margin:1em 0;} h1,h2,h3,h4,h5,h6{border:0;} h1{font-size:170%;border-bottom:3px solid #aaa;padding-top:.5em;padding-bottom:.5em;margin-top:1.5em;} h1:first-child{margin-top:0;padding-bottom:.25em;border-top:none;} h2{font-size:150%;margin-top:1.5em;border-bottom:3px solid #e0e0e0;padding-bottom:0.5em;} h3{margin-top:1em;} hr{border:1px solid #ddd;} ul{margin:1em 0 1em 2em;} ol{margin:1em 0 1em 2em;} ul li,ol li{margin-top:.5em;margin-bottom:.5em;} ul ul,ul ol,ol ol,ol ul{margin-top:0;margin-bottom:0;} blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;} dt{font-weight:bold;margin-left:1em;} dd{margin-left:2em;margin-bottom:1em;} @media screen and (min-width: 768px) { body { width: 748px; margin:10px auto; } } </style><style id=\"custom\" type=\"text/css\"></style></head> <body marginheight=\"0\">";
char *css = "<meta http-equiv=Content-Type content=text/html; charset=UTF-8> <style id=\"system\" type=\"text/css\">*{margin:0;padding:0;} html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; background:#eeeeee;} body { font:15px helvetica,arial,freesans,clean,sans-serif; color:black; line-height:1.4em; background-color: #FFF; padding: 0.7em;} p { margin:1em 0; line-height:1.5em;} table { font-size:inherit; font:100%; margin:1em;} table th{border-bottom:1px solid #bbb;padding:.2em 1em;} table td{border-bottom:1px solid #ddd;padding:.2em 1em;} input[type=text],input[type=password],input[type=image],textarea{font:99\% helvetica,arial,freesans,sans-serif;} select,option{padding:0 .25em;} optgroup{margin-top:.5em;} pre,code{font:13px \"DejaVu Sans Mono\",\"Bitstream Vera Sans Mono\",monospace;} pre { margin:1em 0; font-size:13px; background-color:#eee; border:1px solid #ddd; padding:5px; line-height:1.5em; color:#444; overflow:auto; -webkit-box-shadow:rgba(0,0,0,0.07) 0 1px 2px inset; -webkit-border-radius:3px; -moz-border-radius:3px;border-radius:3px;} pre code { padding:0; font-size:13px; background-color:#eee; border:none;} code { font-size:13px; background-color:#eee; color:#d14; pading:2px 4px border:1px solid #elele8;border-radius:3px} img{border:0;max-width:100%;} abbr{border-bottom:none;} a{color:#4183c4;text-decoration:none;} a:hover{text-decoration:underline;} a code,a:link code,a:visited code{color:#4183c4;} h2,h3{margin:1em 0;} h1,h2,h3,h4,h5,h6{border:0;} h1{font-size:170%;border-bottom:3px solid #aaa;padding-top:.5em;padding-bottom:.5em;margin-top:1.5em;} h1:first-child{margin-top:0;padding-bottom:.25em;border-top:none;} h2{font-size:150%;margin-top:1.5em;border-bottom:3px solid #e0e0e0;padding-bottom:0.5em;} h3{margin-top:1em;} hr{border:1px solid #ddd;} ul{margin:1em 0 1em 2em;} ol{margin:1em 0 1em 2em;} ul li,ol li{margin-top:.5em;margin-bottom:.5em;} ul ul,ul ol,ol ol,ol ul{margin-top:0;margin-bottom:0;} blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;} dt{font-weight:bold;margin-left:1em;} dd{margin-left:2em;margin-bottom:1em;} @media screen and (min-width: 768px) { body { width: 748px; margin:10px auto; } } </style><style id=\"custom\" type=\"text/css\"></style></head> <body marginheight=\"0\">";
91 changes: 91 additions & 0 deletions markdown/fmt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<html><meta http-equiv=Content-Type content=text/html; charset=UTF-8> <style id="system" type="text/css">*{margin:0;padding:0;} html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; background:#eeeeee;} body { font:15px helvetica,arial,freesans,clean,sans-serif; color:black; line-height:1.4em; background-color: #FFF; padding: 0.7em;} p { margin:1em 0; line-height:1.5em;} table { font-size:inherit; font:100%; margin:1em;} table th{border-bottom:1px solid #bbb;padding:.2em 1em;} table td{border-bottom:1px solid #ddd;padding:.2em 1em;} input[type=text],input[type=password],input[type=image],textarea{font:99% helvetica,arial,freesans,sans-serif;} select,option{padding:0 .25em;} optgroup{margin-top:.5em;} pre,code{font:13px "DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;} pre { margin:1em 0; font-size:13px; background-color:#eee; border:1px solid #ddd; padding:5px; line-height:1.5em; color:#444; overflow:auto; -webkit-box-shadow:rgba(0,0,0,0.07) 0 1px 2px inset; -webkit-border-radius:3px; -moz-border-radius:3px;border-radius:3px;} pre code { padding:0; font-size:13px; background-color:#eee; border:none;} code { font-size:13px; background-color:#eee; color:#d14; pading:2px 4px border:1px solid #elele8;border-radius:3px} img{border:0;max-width:100%;} abbr{border-bottom:none;} a{color:#4183c4;text-decoration:none;} a:hover{text-decoration:underline;} a code,a:link code,a:visited code{color:#4183c4;} h2,h3{margin:1em 0;} h1,h2,h3,h4,h5,h6{border:0;} h1{font-size:170%;border-bottom:3px solid #aaa;padding-top:.5em;padding-bottom:.5em;margin-top:1.5em;} h1:first-child{margin-top:0;padding-bottom:.25em;border-top:none;} h2{font-size:150%;margin-top:1.5em;border-bottom:3px solid #e0e0e0;padding-bottom:0.5em;} h3{margin-top:1em;} hr{border:1px solid #ddd;} ul{margin:1em 0 1em 2em;} ol{margin:1em 0 1em 2em;} ul li,ol li{margin-top:.5em;margin-bottom:.5em;} ul ul,ul ol,ol ol,ol ul{margin-top:0;margin-bottom:0;} blockquote{margin:1em 0;border-left:5px solid #ddd;padding-left:.6em;color:#555;} dt{font-weight:bold;margin-left:1em;} dd{margin-left:2em;margin-bottom:1em;} @media screen and (min-width: 768px) { body { width: 748px; margin:10px auto; } } </style><style id="custom" type="text/css"></style></head> <body marginheight="0"><p>fmt位域图:
</p><p>
</p><p>![image text](Work/fmt_field.png)
</p><p>
</p><h2>hash table</h2>
<p>初始化了桶个数为<code>0x400000</code>的哈希表,每个桶长度是2。这样每个桶正好占用一个<code>cacheline</code>
</p><pre><p> #define FMT_HEAD_SIZE 0x400000
</pre></p><p>
</p><h2>vlan</h2>
<p>流管理报文的vlan起始设置为2。
</p><pre><p> #define FMT_API_FLOW_PKT_VLAN_BEGIN 2
</pre></p><p>报文进入首先检查vlan(第一个vlan字段)号码是否属于流管理报文,如是流管理报文的vlan范围,检查报文类型是否正确,如果冲突drop报文。
</p><pre><p> dpim_decode_pre:
if((eth->tag >= FMT_API_FLOW_PKT_VLAN_BEGIN) &&(eth->tag < (FMT_API_FLOW_PKT_VLAN_BEGIN +ZXMX_MAX_IPIF_NUM)))
if(cvmx_unlikely(ctl->flow.proto != ETH_P_FMT)) /* 9003 */
</pre></p><p>判断流表报文的第16位的值决定是什么行为0 read, 1 write
</p><pre><p> if (ctl->hdr.cmd) {
fmt_set((md_fmt_t *)(&ctl->flow));
} else {
fmt_search();
}

</pre></p><h3>fmt_add</h3>
<p>fmt_head是全局的为什么还要作为函数参数。
</p><pre><p>/* refresh the action */
fl->k.act = fkey->act;
</pre></p><p>
</p><h3>fmt_set(md_fmt_t *src)</h3>
<p>报文中第3个32字中的前25位是idx,
</p><p>
</p><h3>fmt_search</h3>
<p>如果送进来的idx是invalid的(0x1ffffff),那么需要自己计算。
</p><p>
</p><p>定位到相应的桶然后查看第一个元素:
</p><pre><p> fl = &fmt_head[*hash].h[0];
</pre></p><p>如果第一个不匹配,那么继续处理:
</p><pre><p> #define SUF_MASK_R(x) (~0UL << (x)) /**< 把64位0变成64四位1,然后左移x位 */
/**
* 提取64位的指针的前48位,并把把48位置1.后面置0
*/
static inline md_fmt_t *fmt_slave(md_fmt_t * f)
{
return (md_fmt_t *) (((u64) f & SUF_MASK_R(6)) | (1 << 6));
}
/**
*
static inline md_fmt_t fmt_next(md_fmt_t *f)
{
if (fmt_slave(f)->list & SUF_MASK_R(7))
return cvmx_phys_to_ptr(fmt_slave(f)->list & SUF_MASK_R(7));
else
return NULL;
}
</pre></p><h3>流表结构</h3>
<p>URL阻断作为一个URL_BLOCK和HFA都会实现的功能,即hfa可以去做url匹配(在url被解析到的情况下)。所以对于流表结构有两种情况会更改:
</p><ul>
<li><p>一是打开url总功能开关,用于保存url
</p></li>
<li>
<p>二是reset报文发送后的计数和reset开关,其他模块也能在旁路情况下发送reset
</p></li>
而url、reset更改同一个位域,所以他们的开关组合成两成4种情况(2^n).
</ul>
<p>
</p><p>注意pkts一定放在最后面,因为fmt_add时候,初始化一个流表entry时候,用<code>|0x01</code>进行的初始化报文数。
</p><p>
</p><h3>流表和acl配置的实时性</h3>
<blockquote>
增加了一个<code>real_mode</code>开关
</blockquote>
<h4>real_mode开启情况下</h4>
<ul>
<li><p>对于命中流表<code>drop</code>行为的报文,执行<code>drop</code>,退出
</p></li>
<li>
<p>对于命中流表<code>forward</code>行为的报文,继续走下面acl路径,acl模块更新fmt(<code>forward->drop</code>)的行为和出接口。
</p></li>
<li>
<p>为什么这么做,而不是<code>drop</code>行为的继续:
</p></li>
<ul>
<li><p>1.实时性要求高的是转发行为的(相比较于drop的)
</p></li>
<li>
<p>2.被<code>drop</code>的流会被阻断,建立新的流表
</p></li>
<li>
<p>3.可以开启实时后进行配置,然后一段时间(流老化时间)后,关闭实时开关恢复性能
</p></li>
</ul>
<p align=right>Edit By<a href="mailto:[email protected]"> sqm</a></p></html>
3 changes: 1 addition & 2 deletions markdown/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ int main(int argc, char *argv[])
return -1;
}
/* write css to the file */
write(fd_out, css, strlen(css));
write(fd_out, "<html>", strlen("<html>"));

write(fd_out, css, strlen(css));
decode(fd_in, fd_out);
write(fd_out, tip, strlen(tip));
write(fd_out, "</html>", strlen("</html>"));
Expand Down
2 changes: 1 addition & 1 deletion markdown/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void process_tit(char *buf, int in, int out)
for (lv = 0; buf[lv] == '\t'; lv++);lv++;

write(out, "<ul>\n<li>", strlen("<ul>\n<li>"));
process_normal(buf + lv1 + 1, in, out);
process_normal(buf + lv + 1, in, out);
write(out, "</li>\n", strlen("</li>\n"));
while (get_line(in, buf) > 0) {
if (TIT_1(buf) || TIT_2(buf) || TIT_3(buf)) {
Expand Down

0 comments on commit bf8b060

Please sign in to comment.