-
Notifications
You must be signed in to change notification settings - Fork 0
/
2016-03-27-switchdev-i.html
433 lines (321 loc) · 21.2 KB
/
2016-03-27-switchdev-i.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#222" media="(prefers-color-scheme: dark)"><meta name="generator" content="Hexo 7.0.0-rc1">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha256-HtsXJanqjKTc8vVQjO4YMhiqFoXkfBsjBWcX91T1jr8=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"www.hwchiu.com","root":"/","images":"/images","scheme":"Gemini","darkmode":true,"version":"8.17.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"Searching...","empty":"We didn't find any results for the search: ${query}","hits_time":"${hits} results found in ${time} ms","hits":"${hits} results found"}}</script><script src="/js/config.js"></script>
<meta name="description" content="Introduction Switchdev 在 linux kernel 3.19+ 以後才正式支援的,此專案希望能夠讓整合 hardware switches 與 Linux kernel。 以前的 hardware switch 都有實作自己的 L2/L3 offloading,同時廠商會在 user space 提供自己的 tool 用來操控該 switchdev。 在此架構">
<meta property="og:type" content="article">
<meta property="og:title" content="[Switchdev] Introduuction To Switchdev">
<meta property="og:url" content="https://www.hwchiu.com/2016-03-27-switchdev-i.html">
<meta property="og:site_name" content="Hwchiu Learning Note">
<meta property="og:description" content="Introduction Switchdev 在 linux kernel 3.19+ 以後才正式支援的,此專案希望能夠讓整合 hardware switches 與 Linux kernel。 以前的 hardware switch 都有實作自己的 L2/L3 offloading,同時廠商會在 user space 提供自己的 tool 用來操控該 switchdev。 在此架構">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://lh3.googleusercontent.com/-cj2IIISQSBk/Vvf_UAiHg9I/AAAAAAAAFME/QxCE0N_zMAMMLDssB0MbUZHZbNBLlMNNQCCo/s852-Ic42/beforeSwitch.PNG">
<meta property="og:image" content="https://lh3.googleusercontent.com/-x9BeDYWCBxA/Vvf_UPXkwiI/AAAAAAAAFMI/UdFkhv7AqrUm4yTVvF0AEmdbgGvOdTIbwCCo/s1033-Ic42/AfterSwitch.PNG">
<meta property="og:image" content="https://lh3.googleusercontent.com/-7BWbz43luZw/VwO0afnRVaI/AAAAAAAAFNk/Psakav4xP3MX-8b9N6h_0nAzSllHjkgEQCCo/s824-Ic42/SwitchDev.png">
<meta property="article:published_time" content="2016-03-27T07:25:00.000Z">
<meta property="article:modified_time" content="2023-06-23T05:16:12.594Z">
<meta property="article:author" content="Hwchiu">
<meta property="article:tag" content="System">
<meta property="article:tag" content="Network">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="Kernel">
<meta property="article:tag" content="Switchdev">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lh3.googleusercontent.com/-cj2IIISQSBk/Vvf_UAiHg9I/AAAAAAAAFME/QxCE0N_zMAMMLDssB0MbUZHZbNBLlMNNQCCo/s852-Ic42/beforeSwitch.PNG">
<link rel="canonical" href="https://www.hwchiu.com/2016-03-27-switchdev-i.html">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"en","comments":true,"permalink":"https://www.hwchiu.com/2016-03-27-switchdev-i.html","path":"2016-03-27-switchdev-i.html","title":"[Switchdev] Introduuction To Switchdev"}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>[Switchdev] Introduuction To Switchdev | Hwchiu Learning Note</title>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-54006186-1"></script>
<script class="next-config" data-name="google_analytics" type="application/json">{"tracking_id":"UA-54006186-1","only_pageview":false}</script>
<script src="/js/third-party/analytics/google-analytics.js"></script>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<div class="column">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="Toggle navigation bar" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<p class="site-title">Hwchiu Learning Note</p>
<i class="logo-line"></i>
</a>
<p class="site-subtitle" itemprop="description">kubernetes, sdn, linux,devops</p>
<img class="custom-logo-image" src="/uploads/hwchiu.jpg" alt="Hwchiu Learning Note">
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger" aria-label="Search" role="button">
</div>
</div>
</div>
<nav class="site-nav">
<ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a></li><li class="menu-item menu-item-sitemap"><a href="/sitemap.xml" rel="section"><i class="fa fa-sitemap fa-fw"></i>Sitemap</a></li>
</ul>
</nav>
</header>
<aside class="sidebar">
<div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
Table of Contents
</li>
<li class="sidebar-nav-overview">
Overview
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
<div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Introduction"><span class="nav-number">1.</span> <span class="nav-text">Introduction</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Before-Switchdev"><span class="nav-number">2.</span> <span class="nav-text">Before Switchdev</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#After-Switchdev"><span class="nav-number">3.</span> <span class="nav-text">After Switchdev</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Vendor-Implementation"><span class="nav-number">4.</span> <span class="nav-text">Vendor Implementation</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Next-Page"><span class="nav-number">5.</span> <span class="nav-text">Next Page</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Reference"><span class="nav-number">6.</span> <span class="nav-text">Reference</span></a></li></ol></div>
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="Hwchiu"
src="/uploads/avatar.jpg">
<p class="site-author-name" itemprop="name">Hwchiu</p>
<div class="site-description" itemprop="description">kubernetes/SDN/DevOps</div>
</div>
<div class="site-state-wrap animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">352</span>
<span class="site-state-item-name">posts</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/">
<span class="site-state-item-count">115</span>
<span class="site-state-item-name">tags</span></a>
</div>
</nav>
</div>
<div class="links-of-author animated">
<span class="links-of-author-item">
<a href="https://github.com/hwchiu" title="GitHub → https://github.com/hwchiu" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="mailto:sppsorrg@gmail.com" title="E-Mail → mailto:sppsorrg@gmail.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
</span>
<span class="links-of-author-item">
<a href="https://twitter.com/hw_chiu" title="Twitter → https://twitter.com/hw_chiu" rel="noopener me" target="_blank"><i class="fab fa-twitter fa-fw"></i>Twitter</a>
</span>
<span class="links-of-author-item">
<a href="https://www.facebook.com/technologynoteniu" title="FB Page → https://www.facebook.com/technologynoteniu" rel="noopener me" target="_blank"><i class="fab fa-facebook fa-fw"></i>FB Page</a>
</span>
<span class="links-of-author-item">
<a href="https://www.youtube.com/channel/UCoYY8K9fbfDtTY7m68UCATA/videos" title="YouTube → https://www.youtube.com/channel/UCoYY8K9fbfDtTY7m68UCATA/videos" rel="noopener me" target="_blank"><i class="fab fa-youtube fa-fw"></i>YouTube</a>
</span>
<span class="links-of-author-item">
<a href="https://instagram.com/hwchiu" title="Instagram → https://instagram.com/hwchiu" rel="noopener me" target="_blank"><i class="fab fa-instagram fa-fw"></i>Instagram</a>
</span>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="main-inner post posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="en">
<link itemprop="mainEntityOfPage" href="https://www.hwchiu.com/2016-03-27-switchdev-i.html">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/uploads/avatar.jpg">
<meta itemprop="name" content="Hwchiu">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Hwchiu Learning Note">
<meta itemprop="description" content="kubernetes/SDN/DevOps">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="[Switchdev] Introduuction To Switchdev | Hwchiu Learning Note">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
[Switchdev] Introduuction To Switchdev
</h1>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">Posted on</span>
<time title="Created: 2016-03-27 15:25:00" itemprop="dateCreated datePublished" datetime="2016-03-27T15:25:00+08:00">2016-03-27</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Modified: 2023-06-23 13:16:12" itemprop="dateModified" datetime="2023-06-23T13:16:12+08:00">2023-06-23</time>
</span>
<span class="post-meta-item" title="Views" id="busuanzi_container_page_pv">
<span class="post-meta-item-icon">
<i class="far fa-eye"></i>
</span>
<span class="post-meta-item-text">Views: </span>
<span id="busuanzi_value_page_pv"></span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody"><h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><ul>
<li><p>Switchdev 在 linux kernel 3.19+ 以後才正式支援的,此專案希望能夠讓整合 hardware switches 與 Linux kernel。</p>
</li>
<li><p>以前的 hardware switch 都有實作自己的 L2/L3 offloading,同時廠商會在 user space 提供自己的 tool 用來操控該 switchdev。</p>
</li>
<li><p>在此架構下,很多常用的 user space tool,如 ethtool, ip, brctl ..等都沒有辦法針對 hardware swtich 去控制,這會使得上層的軟體都要針對不同的底層硬體去客製化處理</p>
</li>
<li><p>為了解決這個問題,希望在 kernel 中加入一層 switchdev,各廠商在 kernel 內實現自己 driver 的 switchdev,然後 swtichdev 本身會與原本的 user space tool 整合,這樣的話 user space 就不用額外提供 tool 了。</p>
<span id="more"></span></li>
</ul>
<p>以下使用 <a target="_blank" rel="noopener" href="http://people.netfilter.org/pablo/netdev0.1/slides/pirko-switchdev-slides.pdf">Hardware switches - the open-source approach</a> 內的圖片來說明</p>
<h2 id="Before-Switchdev"><a href="#Before-Switchdev" class="headerlink" title="Before Switchdev"></a>Before Switchdev</h2><p><img src="https://lh3.googleusercontent.com/-cj2IIISQSBk/Vvf_UAiHg9I/AAAAAAAAFME/QxCE0N_zMAMMLDssB0MbUZHZbNBLlMNNQCCo/s852-Ic42/beforeSwitch.PNG"></p>
<ul>
<li>此圖片顯示的就是目前的狀態,右邊顯示的是一般常見的 kernel 狀況,包含一些 tool 與底層 NIC 是如何操作的。</li>
<li>左邊則是當前 hardware switch 的普遍設計,整個操作都跳過 linux kernel,一切都是廠商自己的程式在處理而已。</li>
<li>當前架構下,沒有辦法於系統上觀察到實體 switchdev 到底有哪些 port,就像現在多數的家用 router 一樣,明明有四個 lan 孔,但是透過 ifconfig 看都只會有一個。</li>
</ul>
<h2 id="After-Switchdev"><a href="#After-Switchdev" class="headerlink" title="After Switchdev"></a>After Switchdev</h2><p><img src="https://lh3.googleusercontent.com/-x9BeDYWCBxA/Vvf_UPXkwiI/AAAAAAAAFMI/UdFkhv7AqrUm4yTVvF0AEmdbgGvOdTIbwCCo/s1033-Ic42/AfterSwitch.PNG"></p>
<ul>
<li>此圖顯示的是 switchdev 此專案希望的架構</li>
<li>此架構中,廠商根據 switchdev 定義好的架構去實現自己的 driver,這樣原生的 tools 都可以直接對真正的 hardware switch 進行操作,廠商也不需要自己在額外開發 user space tool 了。</li>
</ul>
<h2 id="Vendor-Implementation"><a href="#Vendor-Implementation" class="headerlink" title="Vendor Implementation"></a>Vendor Implementation</h2><ul>
<li>第一個實作完成的 switch driver 是 <a target="_blank" rel="noopener" href="http://people.netfilter.org/pablo/netdev0.1/papers/Rocker-switchdev-prototyping-vehicle.pdf">Rocker</a></li>
<li>Rocker 的 code 可以在 kernel 內的 <strong>/drivers/net/ethernet/rocker/</strong> 內看到</li>
<li>Mellanox 的 code 可以在 kernel 內的 <strong>/drivers/net/ethernet/mellanox/mlxsw/</strong> 內看到</li>
</ul>
<h2 id="Next-Page"><a href="#Next-Page" class="headerlink" title="Next Page"></a>Next Page</h2><p>接下來的章節將會介紹 switchdev 在 kernel 內的架構實作以及與 Rocker 這個 switch driver 是如何互動的。<br>大抵架構如下<br><img src="https://lh3.googleusercontent.com/-7BWbz43luZw/VwO0afnRVaI/AAAAAAAAFNk/Psakav4xP3MX-8b9N6h_0nAzSllHjkgEQCCo/s824-Ic42/SwitchDev.png"></p>
<h2 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h2><ul>
<li><a target="_blank" rel="noopener" href="https://www.kernel.org/doc/Documentation/networking/switchdev.txt">kernel document</a></li>
<li><a target="_blank" rel="noopener" href="http://people.netfilter.org/pablo/netdev0.1/slides/pirko-switchdev-slides.pdf">Hardware switches - the open-source approach</a></li>
<li><a target="_blank" rel="noopener" href="http://people.netfilter.org/pablo/netdev0.1/papers/Rocker-switchdev-prototyping-vehicle.pdf">Rocker switchdev prototyping vehicle</a></li>
</ul>
</div>
<footer class="post-footer">
<div class="followme">
<span>Welcome to my other publishing channels</span>
<div class="social-list">
<div class="social-item">
<a target="_blank" class="social-link" href="https://twitter.com/hw_chiu">
<span class="icon">
<i class="fab fa-twitter"></i>
</span>
<span class="label">Twitter</span>
</a>
</div>
<div class="social-item">
<a target="_blank" class="social-link" href="https://t.me/technologynote">
<span class="icon">
<i class="fab fa-telegram"></i>
</span>
<span class="label">Telegram</span>
</a>
</div>
<div class="social-item">
<a target="_blank" class="social-link" href="/atom.xml">
<span class="icon">
<i class="fa fa-rss"></i>
</span>
<span class="label">RSS</span>
</a>
</div>
</div>
</div>
<div class="post-tags">
<a href="/tags/System/" rel="tag"># System</a>
<a href="/tags/Network/" rel="tag"># Network</a>
<a href="/tags/Linux/" rel="tag"># Linux</a>
<a href="/tags/Kernel/" rel="tag"># Kernel</a>
<a href="/tags/Switchdev/" rel="tag"># Switchdev</a>
</div>
<div class="post-nav">
<div class="post-nav-item">
<a href="/netfilter-nfqueue.html" rel="prev" title="NFQUEUE drop UDP packets">
<i class="fa fa-chevron-left"></i> NFQUEUE drop UDP packets
</a>
</div>
<div class="post-nav-item">
<a href="/2016-04-04-switchdev-ii.html" rel="next" title="[Switchdev] How Kernel Implement SwitchDev(i)">
[Switchdev] How Kernel Implement SwitchDev(i) <i class="fa fa-chevron-right"></i>
</a>
</div>
</div>
</footer>
</article>
</div>
<div class="comments utterances-container"></div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2023</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Hwchiu</span>
</div>
<div class="busuanzi-count">
<span class="post-meta-item" id="busuanzi_container_site_uv">
<span class="post-meta-item-icon">
<i class="fa fa-user"></i>
</span>
<span class="site-uv" title="Total Visitors">
<span id="busuanzi_value_site_uv"></span>
</span>
</span>
<span class="post-meta-item" id="busuanzi_container_site_pv">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="site-pv" title="Total Views">
<span id="busuanzi_value_site_pv"></span>
</span>
</span>
</div>
<div class="powered-by">Powered by <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a>
</div>
</div>
</footer>
<div class="back-to-top" role="button" aria-label="Back to top">
<i class="fa fa-arrow-up fa-lg"></i>
<span>0%</span>
</div>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script class="next-config" data-name="utterances" type="application/json">{"enable":true,"repo":"hwchiu/blog-comment","issue_term":"pathname","theme":"github-light"}</script>
<script src="/js/third-party/comments/utterances.js"></script>
</body>
</html>