Food grade. Don't use the diatomaceous earth sold for swimming pool filters.
Mixing the DE powder in with the food?
Yes. It doesn't take much and is safe to eat (86% silica, 5% sodium, 3% magnesium and 2% iron). Like most dusts, you want to avoid breathing it. Food grade diatomaceous earth is routinely used for control of grain eating insects.
Or are you saying to put in packets or something?
No, blend it directly with the grain/flour/meal. Since it's ok for human consumption, consider mixing it with other bulk dried foods.
Here's an overview on diatomacious earth you can use as a starting point for further research. http://en.wikipedia.org/wiki/Diatomaceous_earth#cite_note-3