Calmisi Lee

Never like what you think.


  • Home

  • Archives

  • Tags

  • Categories

  • About

  • Search

dpdk l2fwd 源码解析

Posted on 2017-05-09 | Edited on 2019-02-01 | In DPDK | Views:
Symbols count in article: 9.3k | Reading time ≈ 8 mins.

本文对DPDK17.02自带的example l2fwd进行走读解析。

Read more »

搭建shadowsocks server

Posted on 2017-04-27 | Edited on 2018-09-16 | In Linux | Views:
Symbols count in article: 5.6k | Reading time ≈ 5 mins.

自从搬了新实验室,虽然都是校内网,无奈网络差太多,LOL都打不了。

今天发现了有Proxifier这个东西,它可以将基于SOCK5的代理变为操作系统全局的。
这样就可以先ssh连上服务器221(221服务器所在的机房的网络好嘛,打游戏方便)。
在221的ssh上创建一个基于SOCK5的动态隧道。
然后用Proxifier将这个SOCK5的代理设为全局的,就可以用221服务器那边的网络玩LOL啦。

可是实验发现基于SSH隧道的SOCK5代理,用了proxifier还是只能代理浏览器的流量,真烦心。
没办法,只能尝试用SS的SOCK5代理了,首先用我的境外SS账号测试,发现基于SS的proxifier全局代理可以代理其他应用(非浏览器,如chrome)的流量。
那么要用221的网打LOL,只能在221上装一个SS的server了。

Read more »

linux mmap()函数

Posted on 2017-04-20 | Edited on 2018-09-16 | In 系统函数 | Views:
Symbols count in article: 2.5k | Reading time ≈ 2 mins.

头文件:#include <unistd.h> #include <sys/mman.h>

定义函数:void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offsize);

参数说明:

































参数

说明

start

指向欲对应的内存起始地址,通常设为NULL,代表让系统自动选定地址,对应成功后该地址会返回。

length

代表将文件中多大的部分对应到内存。

prot

 代表映射区域的保护方式,有下列组合:


  • PROT_EXEC  映射区域可被执行;


  • PROT_READ  映射区域可被读取;


  • PROT_WRITE  映射区域可被写入;


  • PROT_NONE  映射区域不能存取。



flags

会影响映射区域的各种特性:


  • MAP_FIXED  如果参数 start 所指的地址无法成功建立映射时,则放弃映射,不对地址做修正。通常不鼓励用此旗标。


  • MAP_SHARED  对应射区域的写入数据会复制回文件内,而且允许其他映射该文件的进程共享。


  • MAP_PRIVATE  对应射区域的写入操作会产生一个映射文件的复制,即私人的"写入时复制" (copy on write)对此区域作的任何修改都不会写回原来的文件内容。


  • MAP_ANONYMOUS  建立匿名映射,此时会忽略参数fd,不涉及文件,而且映射区域无法和其他进程共享。


  • MAP_DENYWRITE  只允许对应射区域的写入操作,其他对文件直接写入的操作将会被拒绝。


  • MAP_LOCKED  将映射区域锁定住,这表示该区域不会被置换(swap)。




在调用mmap()时必须要指定MAP_SHARED 或MAP_PRIVATE。

fd

open()返回的文件描述词,代表欲映射到内存的文件。

offset

文件映射的偏移量,通常设置为0,代表从文件最前方开始对应,offset必须是分页大小的整数倍。

返回值:若映射成功则返回映射区的内存起始地址,否则返回MAP_FAILED(-1),错误原因存于errno 中。

错误代码:

  • EBADF 参数fd 不是有效的文件描述词。
  • EACCES 存取权限有误。如果是MAP_PRIVATE 情况下文件必须可读,使用MAP_SHARED 则要有PROT_WRITE 以及该文件要能写入。
  • EINVAL 参数start、length 或offset 有一个不合法。
  • EAGAIN 文件被锁住,或是有太多内存被锁住。
  • ENOMEM 内存不足。

范例:利用mmap()来读取/etc/passwd 文件内容。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
main(){
int fd;
void *start;
struct stat sb;
fd = open("/etc/passwd", O_RDONLY); /*打开/etc/passwd */
fstat(fd, &sb); /* 取得文件大小 */
start = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if(start == MAP_FAILED) /* 判断是否映射成功 */
return;
printf("%s", start); munma(start, sb.st_size); /* 解除映射 */
closed(fd);
}

执行结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
root : x : 0 : root : /root : /bin/bash
bin : x : 1 : 1 : bin : /bin :
daemon : x : 2 : 2 :daemon : /sbin
adm : x : 3 : 4 : adm : /var/adm :
lp : x :4 :7 : lp : /var/spool/lpd :
sync : x : 5 : 0 : sync : /sbin : bin/sync :
shutdown : x : 6 : 0 : shutdown : /sbin : /sbin/shutdown
halt : x : 7 : 0 : halt : /sbin : /sbin/halt
mail : x : 8 : 12 : mail : /var/spool/mail :
news : x :9 :13 : news : /var/spool/news :
uucp : x :10 :14 : uucp : /var/spool/uucp :
operator : x : 11 : 0 :operator : /root:
games : x : 12 :100 : games :/usr/games:
gopher : x : 13 : 30 : gopher : /usr/lib/gopher-data:
ftp : x : 14 : 50 : FTP User : /home/ftp:
nobody : x :99: 99: Nobody : /:
xfs :x :100 :101 : X Font Server : /etc/xll/fs : /bin/false
gdm : x : 42 :42 : : /home/gdm: /bin/bash
kids : x : 500 :500 :/home/kids : /bin/bash

vc709 BAR空间地址&寄存器设置

Posted on 2017-03-30 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 1.2k | Reading time ≈ 1 mins.

本文记录Xilinx VC709这块开发板的PCI BAR空间的设置相关信息。

Read more »

Linux内存分配方法总结

Posted on 2017-03-24 | Edited on 2018-09-16 | In Linux | Views:
Symbols count in article: 2.9k | Reading time ≈ 3 mins.

本文转自: http://www.cnblogs.com/wenhuisun/archive/2013/05/15/3079722.html

Read more »

vc709 start/stop Test 过程分析

Posted on 2017-03-24 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 5.6k | Reading time ≈ 5 mins.

本文分析VC709板卡自带的TRD程序中对应JAVA GUI界面的start和stop按钮对应的startTest和stopTest功能。
当选择performance mode的时候,GUI进入的界面可以设置四个DMA engine的包大小和选择对应的模式:
performance: loopback,pktchk,pktgen;
performance+raw_ethernet: loopback;
然后点击start,则App程序开始发包,点stop则程序App程序停止发包。

下面具体分析点击start和stop时,GUI程序给xdma驱动发送了什么命令,对FPGA进行了怎么样的配置。

Read more »

DMA的一些基础知识

Posted on 2017-03-20 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 5.6k | Reading time ≈ 5 mins.

本文介绍DMA的基础知识
本文转自 http://blog.csdn.net/kafeiflynn/article/details/6665743

Read more »

vc709 DMA 驱动程序源码理解

Posted on 2017-03-19 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 9.7k | Reading time ≈ 9 mins.

看了一周的vc709这块板子自带的驱动程序的源码,现作点总结,以便往后回顾。

Read more »

xdma源码解读

Posted on 2017-03-15 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 7.2k | Reading time ≈ 7 mins.
  1. A buffer descriptor defines a DMA transaction.
  2. the Dma_Bd结构体定义了BD;

xdma.h

xdma驱动支持以下特性:

  1. Scatter-Gather DMA (SGDMA)
  2. Interrupts
  3. Interrupts are coalesced by the driver to improve performance
  4. 32-bit addressing for Buffer Descriptors (BDs) and data buffers
  5. APIs to manage BD movement to and from the SGDMA engine
  6. Virtual memory support
  7. PCI Express support
  8. Performance measurement statistics
  9. APIs to enable DMA driver to be used by other application drivers
    Read more »

xraw_data driver解析

Posted on 2017-03-09 | Edited on 2018-09-16 | In vc709 DMA 驱动 | Views:
Symbols count in article: 5.7k | Reading time ≈ 5 mins.

Xilinx VC709开发板,对应的程序中有个performance mode,是查看DMA性能的。
该板子的DMA驱动为xdma_v7.ko,在路径linux_driver_app/driver/xdma中。
选择performance mode后,该模式只使用一个DMA engine(即engine 0),其有2个通道分别为TX和RX,
对应的设备驱动为xrawdata0.ko,在路径linux_driver_app/driver/xrawdata0中,对应的驱动源程序为sgusr.c。

xraw_data0的驱动需要向XDMA的驱动注册,以完成相应的接口,其在系统中的接口为一个字符文件/dev/xraw_data0。

下面我们具体来看sgusr.c文件的源码。

Read more »
1…345…7
Calmisi Lee

Calmisi Lee

Pas de regrets

67 posts
19 categories
52 tags
GitHub E-Mail
0%
© 2015.6 – 2019 Calmisi Lee | Symbols count total: 319k | Reading time total ≈ 4:50
Powered by Hexo
|
Theme – NexT.Pisces v7.0.0